vant 4.9.2 → 4.9.3
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/es/calendar/CalendarHeader.mjs +5 -17
- package/es/calendar/utils.mjs +6 -0
- package/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/es/text-ellipsis/TextEllipsis.mjs +56 -46
- package/es/uploader/Uploader.mjs +6 -8
- package/es/uploader/types.d.ts +1 -0
- package/lib/calendar/CalendarHeader.js +4 -16
- package/lib/calendar/utils.js +6 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/text-ellipsis/TextEllipsis.js +55 -45
- package/lib/uploader/Uploader.js +6 -8
- package/lib/uploader/types.d.ts +1 -0
- package/lib/vant.cjs.js +72 -70
- package/lib/vant.es.js +72 -70
- package/lib/vant.js +73 -71
- package/lib/vant.min.js +3 -3
- package/lib/web-types.json +1 -1
- package/package.json +12 -12
@@ -1,7 +1,7 @@
|
|
1
1
|
import { createVNode as _createVNode } from "vue";
|
2
2
|
import { computed, defineComponent } from "vue";
|
3
3
|
import { createNamespace, HAPTICS_FEEDBACK, makeStringProp } from "../utils/index.mjs";
|
4
|
-
import { t, bem, getPrevMonth, getPrevYear, getNextMonth, getNextYear } from "./utils.mjs";
|
4
|
+
import { t, bem, compareMonth, getPrevMonth, getPrevYear, getNextMonth, getNextYear } from "./utils.mjs";
|
5
5
|
import { Icon } from "../icon/index.mjs";
|
6
6
|
const [name] = createNamespace("calendar-header");
|
7
7
|
var stdin_default = defineComponent({
|
@@ -22,22 +22,10 @@ var stdin_default = defineComponent({
|
|
22
22
|
slots,
|
23
23
|
emit
|
24
24
|
}) {
|
25
|
-
const prevMonthDisabled = computed(() =>
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
const prevYearDisabled = computed(() => {
|
30
|
-
const prevYear = getPrevYear(props.date);
|
31
|
-
return props.minDate && prevYear < props.minDate;
|
32
|
-
});
|
33
|
-
const nextMonthDisabled = computed(() => {
|
34
|
-
const nextMonth = getNextMonth(props.date);
|
35
|
-
return props.maxDate && nextMonth > props.maxDate;
|
36
|
-
});
|
37
|
-
const nextYearDisabled = computed(() => {
|
38
|
-
const nextYear = getNextYear(props.date);
|
39
|
-
return props.maxDate && nextYear > props.maxDate;
|
40
|
-
});
|
25
|
+
const prevMonthDisabled = computed(() => props.date && props.minDate && compareMonth(getPrevMonth(props.date), props.minDate) < 0);
|
26
|
+
const prevYearDisabled = computed(() => props.date && props.minDate && compareMonth(getPrevYear(props.date), props.minDate) < 0);
|
27
|
+
const nextMonthDisabled = computed(() => props.date && props.maxDate && compareMonth(getNextMonth(props.date), props.maxDate) > 0);
|
28
|
+
const nextYearDisabled = computed(() => props.date && props.maxDate && compareMonth(getNextYear(props.date), props.maxDate) > 0);
|
41
29
|
const renderTitle = () => {
|
42
30
|
if (props.showTitle) {
|
43
31
|
const text = props.title || t("title");
|
package/es/calendar/utils.mjs
CHANGED
@@ -30,11 +30,17 @@ function getDayByOffset(date, offset) {
|
|
30
30
|
function getMonthByOffset(date, offset) {
|
31
31
|
const cloned = cloneDate(date);
|
32
32
|
cloned.setMonth(cloned.getMonth() + offset);
|
33
|
+
if (cloned.getDate() !== date.getDate()) {
|
34
|
+
cloned.setDate(0);
|
35
|
+
}
|
33
36
|
return cloned;
|
34
37
|
}
|
35
38
|
function getYearByOffset(date, offset) {
|
36
39
|
const cloned = cloneDate(date);
|
37
40
|
cloned.setFullYear(cloned.getFullYear() + offset);
|
41
|
+
if (cloned.getDate() !== date.getDate()) {
|
42
|
+
cloned.setDate(0);
|
43
|
+
}
|
38
44
|
return cloned;
|
39
45
|
}
|
40
46
|
const getPrevDay = (date) => getDayByOffset(date, -1);
|
package/es/index.d.ts
CHANGED
package/es/index.mjs
CHANGED
@@ -99,7 +99,7 @@ import { Toast } from "./toast/index.mjs";
|
|
99
99
|
import { TreeSelect } from "./tree-select/index.mjs";
|
100
100
|
import { Uploader } from "./uploader/index.mjs";
|
101
101
|
import { Watermark } from "./watermark/index.mjs";
|
102
|
-
const version = "4.9.
|
102
|
+
const version = "4.9.3";
|
103
103
|
function install(app) {
|
104
104
|
const components = [
|
105
105
|
ActionBar,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { createVNode as _createVNode } from "vue";
|
2
|
-
import { ref, watch, computed, onActivated, onMounted, defineComponent } from "vue";
|
2
|
+
import { ref, watch, computed, onActivated, onMounted, defineComponent, nextTick } from "vue";
|
3
3
|
import { makeNumericProp, makeStringProp, createNamespace, windowWidth } from "../utils/index.mjs";
|
4
4
|
import { useExpose } from "../composables/use-expose.mjs";
|
5
5
|
const [name, bem] = createNamespace("text-ellipsis");
|
@@ -19,10 +19,11 @@ var stdin_default = defineComponent({
|
|
19
19
|
emit,
|
20
20
|
slots
|
21
21
|
}) {
|
22
|
-
const text = ref(
|
22
|
+
const text = ref(props.content);
|
23
23
|
const expanded = ref(false);
|
24
24
|
const hasAction = ref(false);
|
25
25
|
const root = ref();
|
26
|
+
const actionRef = ref();
|
26
27
|
let needRecalculate = false;
|
27
28
|
const actionText = computed(() => expanded.value ? props.collapseText : props.expandText);
|
28
29
|
const pxToNum = (value) => {
|
@@ -50,57 +51,60 @@ var stdin_default = defineComponent({
|
|
50
51
|
document.body.appendChild(container);
|
51
52
|
return container;
|
52
53
|
};
|
53
|
-
const
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
}
|
67
|
-
return dots + content.slice(right, end);
|
68
|
-
}
|
69
|
-
const middle2 = Math.round((left + right) / 2);
|
54
|
+
const calcEllipsisText = (container, maxHeight) => {
|
55
|
+
var _a, _b;
|
56
|
+
const {
|
57
|
+
content,
|
58
|
+
position,
|
59
|
+
dots
|
60
|
+
} = props;
|
61
|
+
const end = content.length;
|
62
|
+
const middle = 0 + end >> 1;
|
63
|
+
const actionHTML = slots.action ? (_b = (_a = actionRef.value) == null ? void 0 : _a.outerHTML) != null ? _b : "" : props.expandText;
|
64
|
+
const calcEllipse = () => {
|
65
|
+
const tail = (left, right) => {
|
66
|
+
if (right - left <= 1) {
|
70
67
|
if (position === "end") {
|
71
|
-
|
72
|
-
} else {
|
73
|
-
container2.innerText = dots + content.slice(middle2, end) + actionText.value;
|
74
|
-
}
|
75
|
-
if (container2.offsetHeight > maxHeight2) {
|
76
|
-
if (position === "end") {
|
77
|
-
return tail(left, middle2);
|
78
|
-
}
|
79
|
-
return tail(middle2, right);
|
68
|
+
return content.slice(0, left) + dots;
|
80
69
|
}
|
70
|
+
return dots + content.slice(right, end);
|
71
|
+
}
|
72
|
+
const middle2 = Math.round((left + right) / 2);
|
73
|
+
if (position === "end") {
|
74
|
+
container.innerText = content.slice(0, middle2) + dots;
|
75
|
+
} else {
|
76
|
+
container.innerText = dots + content.slice(middle2, end);
|
77
|
+
}
|
78
|
+
container.innerHTML += actionHTML;
|
79
|
+
if (container.offsetHeight > maxHeight) {
|
81
80
|
if (position === "end") {
|
82
|
-
return tail(
|
81
|
+
return tail(left, middle2);
|
83
82
|
}
|
84
|
-
return tail(
|
85
|
-
};
|
86
|
-
container2.innerText = tail(0, end);
|
87
|
-
};
|
88
|
-
const middleTail = (leftPart, rightPart) => {
|
89
|
-
if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
90
|
-
return content.slice(0, leftPart[0]) + dots + content.slice(rightPart[1], end);
|
83
|
+
return tail(middle2, right);
|
91
84
|
}
|
92
|
-
|
93
|
-
|
94
|
-
container2.innerText = props.content.slice(0, leftMiddle) + props.dots + props.content.slice(rightMiddle, end) + props.expandText;
|
95
|
-
if (container2.offsetHeight >= maxHeight2) {
|
96
|
-
return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
|
85
|
+
if (position === "end") {
|
86
|
+
return tail(middle2, right);
|
97
87
|
}
|
98
|
-
return
|
88
|
+
return tail(left, middle2);
|
99
89
|
};
|
100
|
-
|
101
|
-
|
102
|
-
|
90
|
+
return tail(0, end);
|
91
|
+
};
|
92
|
+
const middleTail = (leftPart, rightPart) => {
|
93
|
+
if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
94
|
+
return content.slice(0, leftPart[0]) + dots + content.slice(rightPart[1], end);
|
95
|
+
}
|
96
|
+
const leftMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
97
|
+
const rightMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
98
|
+
container.innerText = props.content.slice(0, leftMiddle) + props.dots + props.content.slice(rightMiddle, end);
|
99
|
+
container.innerHTML += actionHTML;
|
100
|
+
if (container.offsetHeight >= maxHeight) {
|
101
|
+
return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
|
102
|
+
}
|
103
|
+
return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
|
103
104
|
};
|
105
|
+
return props.position === "middle" ? middleTail([0, middle], [middle, end]) : calcEllipse();
|
106
|
+
};
|
107
|
+
const calcEllipsised = () => {
|
104
108
|
const container = cloneContainer();
|
105
109
|
if (!container) {
|
106
110
|
needRecalculate = true;
|
@@ -133,11 +137,17 @@ var stdin_default = defineComponent({
|
|
133
137
|
expanded: expanded.value
|
134
138
|
}) : actionText.value;
|
135
139
|
return _createVNode("span", {
|
140
|
+
"ref": actionRef,
|
136
141
|
"class": bem("action"),
|
137
142
|
"onClick": onClickAction
|
138
143
|
}, [action]);
|
139
144
|
};
|
140
|
-
onMounted(
|
145
|
+
onMounted(() => {
|
146
|
+
calcEllipsised();
|
147
|
+
if (slots.action) {
|
148
|
+
nextTick(calcEllipsised);
|
149
|
+
}
|
150
|
+
});
|
141
151
|
onActivated(() => {
|
142
152
|
if (needRecalculate) {
|
143
153
|
needRecalculate = false;
|
package/es/uploader/Uploader.mjs
CHANGED
@@ -183,7 +183,7 @@ var stdin_default = defineComponent({
|
|
183
183
|
emit("update:modelValue", fileList);
|
184
184
|
emit("delete", item, getDetail(index));
|
185
185
|
};
|
186
|
-
const
|
186
|
+
const reuploadFile = (index) => {
|
187
187
|
isReuploading.value = true;
|
188
188
|
reuploadIndex.value = index;
|
189
189
|
nextTick(() => chooseFile());
|
@@ -203,7 +203,7 @@ var stdin_default = defineComponent({
|
|
203
203
|
"onClick": () => emit(props.reupload ? "clickReupload" : "clickPreview", item, getDetail(index)),
|
204
204
|
"onDelete": () => deleteFile(item, index),
|
205
205
|
"onPreview": () => previewImage(item),
|
206
|
-
"onReupload": () =>
|
206
|
+
"onReupload": () => reuploadFile(index)
|
207
207
|
}, pick(props, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
|
208
208
|
};
|
209
209
|
const renderPreviewList = () => {
|
@@ -213,10 +213,7 @@ var stdin_default = defineComponent({
|
|
213
213
|
};
|
214
214
|
const onClickUpload = (event) => emit("clickUpload", event);
|
215
215
|
const renderUpload = () => {
|
216
|
-
|
217
|
-
return;
|
218
|
-
}
|
219
|
-
const hideUploader = props.modelValue.length >= +props.maxCount && props.reupload;
|
216
|
+
const lessThanMax = props.modelValue.length < +props.maxCount;
|
220
217
|
const Input = props.readonly ? null : _createVNode("input", {
|
221
218
|
"ref": inputRef,
|
222
219
|
"type": "file",
|
@@ -232,7 +229,7 @@ var stdin_default = defineComponent({
|
|
232
229
|
return _withDirectives(_createVNode("div", {
|
233
230
|
"class": bem("input-wrapper"),
|
234
231
|
"onClick": onClickUpload
|
235
|
-
}, [slots.default(), Input]), [[_vShow,
|
232
|
+
}, [slots.default(), Input]), [[_vShow, lessThanMax]]);
|
236
233
|
}
|
237
234
|
return _withDirectives(_createVNode("div", {
|
238
235
|
"class": bem("upload", {
|
@@ -245,7 +242,7 @@ var stdin_default = defineComponent({
|
|
245
242
|
"class": bem("upload-icon")
|
246
243
|
}, null), props.uploadText && _createVNode("span", {
|
247
244
|
"class": bem("upload-text")
|
248
|
-
}, [props.uploadText]), Input]), [[_vShow, props.showUpload &&
|
245
|
+
}, [props.uploadText]), Input]), [[_vShow, props.showUpload && lessThanMax]]);
|
249
246
|
};
|
250
247
|
const chooseFile = () => {
|
251
248
|
if (inputRef.value && !props.disabled) {
|
@@ -257,6 +254,7 @@ var stdin_default = defineComponent({
|
|
257
254
|
});
|
258
255
|
useExpose({
|
259
256
|
chooseFile,
|
257
|
+
reuploadFile,
|
260
258
|
closeImagePreview
|
261
259
|
});
|
262
260
|
useCustomFieldValue(() => props.modelValue);
|
package/es/uploader/types.d.ts
CHANGED
@@ -29,6 +29,7 @@ export type UploaderAfterRead = (items: UploaderFileListItem | UploaderFileListI
|
|
29
29
|
export type UploaderExpose = {
|
30
30
|
chooseFile: () => void;
|
31
31
|
closeImagePreview: () => void;
|
32
|
+
reuploadFile: (index: number) => void;
|
32
33
|
};
|
33
34
|
export type UploaderInstance = ComponentPublicInstance<UploaderProps, UploaderExpose>;
|
34
35
|
export type UploaderThemeVars = {
|
@@ -44,22 +44,10 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
44
44
|
slots,
|
45
45
|
emit
|
46
46
|
}) {
|
47
|
-
const prevMonthDisabled = (0, import_vue2.computed)(() =>
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
const prevYearDisabled = (0, import_vue2.computed)(() => {
|
52
|
-
const prevYear = (0, import_utils2.getPrevYear)(props.date);
|
53
|
-
return props.minDate && prevYear < props.minDate;
|
54
|
-
});
|
55
|
-
const nextMonthDisabled = (0, import_vue2.computed)(() => {
|
56
|
-
const nextMonth = (0, import_utils2.getNextMonth)(props.date);
|
57
|
-
return props.maxDate && nextMonth > props.maxDate;
|
58
|
-
});
|
59
|
-
const nextYearDisabled = (0, import_vue2.computed)(() => {
|
60
|
-
const nextYear = (0, import_utils2.getNextYear)(props.date);
|
61
|
-
return props.maxDate && nextYear > props.maxDate;
|
62
|
-
});
|
47
|
+
const prevMonthDisabled = (0, import_vue2.computed)(() => props.date && props.minDate && (0, import_utils2.compareMonth)((0, import_utils2.getPrevMonth)(props.date), props.minDate) < 0);
|
48
|
+
const prevYearDisabled = (0, import_vue2.computed)(() => props.date && props.minDate && (0, import_utils2.compareMonth)((0, import_utils2.getPrevYear)(props.date), props.minDate) < 0);
|
49
|
+
const nextMonthDisabled = (0, import_vue2.computed)(() => props.date && props.maxDate && (0, import_utils2.compareMonth)((0, import_utils2.getNextMonth)(props.date), props.maxDate) > 0);
|
50
|
+
const nextYearDisabled = (0, import_vue2.computed)(() => props.date && props.maxDate && (0, import_utils2.compareMonth)((0, import_utils2.getNextYear)(props.date), props.maxDate) > 0);
|
63
51
|
const renderTitle = () => {
|
64
52
|
if (props.showTitle) {
|
65
53
|
const text = props.title || (0, import_utils2.t)("title");
|
package/lib/calendar/utils.js
CHANGED
@@ -70,11 +70,17 @@ function getDayByOffset(date, offset) {
|
|
70
70
|
function getMonthByOffset(date, offset) {
|
71
71
|
const cloned = cloneDate(date);
|
72
72
|
cloned.setMonth(cloned.getMonth() + offset);
|
73
|
+
if (cloned.getDate() !== date.getDate()) {
|
74
|
+
cloned.setDate(0);
|
75
|
+
}
|
73
76
|
return cloned;
|
74
77
|
}
|
75
78
|
function getYearByOffset(date, offset) {
|
76
79
|
const cloned = cloneDate(date);
|
77
80
|
cloned.setFullYear(cloned.getFullYear() + offset);
|
81
|
+
if (cloned.getDate() !== date.getDate()) {
|
82
|
+
cloned.setDate(0);
|
83
|
+
}
|
78
84
|
return cloned;
|
79
85
|
}
|
80
86
|
const getPrevDay = (date) => getDayByOffset(date, -1);
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
@@ -226,7 +226,7 @@ __reExport(stdin_exports, require("./toast"), module.exports);
|
|
226
226
|
__reExport(stdin_exports, require("./tree-select"), module.exports);
|
227
227
|
__reExport(stdin_exports, require("./uploader"), module.exports);
|
228
228
|
__reExport(stdin_exports, require("./watermark"), module.exports);
|
229
|
-
const version = "4.9.
|
229
|
+
const version = "4.9.3";
|
230
230
|
function install(app) {
|
231
231
|
const components = [
|
232
232
|
import_action_bar.ActionBar,
|
@@ -42,10 +42,11 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
42
42
|
emit,
|
43
43
|
slots
|
44
44
|
}) {
|
45
|
-
const text = (0, import_vue2.ref)(
|
45
|
+
const text = (0, import_vue2.ref)(props.content);
|
46
46
|
const expanded = (0, import_vue2.ref)(false);
|
47
47
|
const hasAction = (0, import_vue2.ref)(false);
|
48
48
|
const root = (0, import_vue2.ref)();
|
49
|
+
const actionRef = (0, import_vue2.ref)();
|
49
50
|
let needRecalculate = false;
|
50
51
|
const actionText = (0, import_vue2.computed)(() => expanded.value ? props.collapseText : props.expandText);
|
51
52
|
const pxToNum = (value) => {
|
@@ -73,57 +74,60 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
73
74
|
document.body.appendChild(container);
|
74
75
|
return container;
|
75
76
|
};
|
76
|
-
const
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
}
|
90
|
-
return dots + content.slice(right, end);
|
91
|
-
}
|
92
|
-
const middle2 = Math.round((left + right) / 2);
|
77
|
+
const calcEllipsisText = (container, maxHeight) => {
|
78
|
+
var _a, _b;
|
79
|
+
const {
|
80
|
+
content,
|
81
|
+
position,
|
82
|
+
dots
|
83
|
+
} = props;
|
84
|
+
const end = content.length;
|
85
|
+
const middle = 0 + end >> 1;
|
86
|
+
const actionHTML = slots.action ? (_b = (_a = actionRef.value) == null ? void 0 : _a.outerHTML) != null ? _b : "" : props.expandText;
|
87
|
+
const calcEllipse = () => {
|
88
|
+
const tail = (left, right) => {
|
89
|
+
if (right - left <= 1) {
|
93
90
|
if (position === "end") {
|
94
|
-
|
95
|
-
} else {
|
96
|
-
container2.innerText = dots + content.slice(middle2, end) + actionText.value;
|
97
|
-
}
|
98
|
-
if (container2.offsetHeight > maxHeight2) {
|
99
|
-
if (position === "end") {
|
100
|
-
return tail(left, middle2);
|
101
|
-
}
|
102
|
-
return tail(middle2, right);
|
91
|
+
return content.slice(0, left) + dots;
|
103
92
|
}
|
93
|
+
return dots + content.slice(right, end);
|
94
|
+
}
|
95
|
+
const middle2 = Math.round((left + right) / 2);
|
96
|
+
if (position === "end") {
|
97
|
+
container.innerText = content.slice(0, middle2) + dots;
|
98
|
+
} else {
|
99
|
+
container.innerText = dots + content.slice(middle2, end);
|
100
|
+
}
|
101
|
+
container.innerHTML += actionHTML;
|
102
|
+
if (container.offsetHeight > maxHeight) {
|
104
103
|
if (position === "end") {
|
105
|
-
return tail(
|
104
|
+
return tail(left, middle2);
|
106
105
|
}
|
107
|
-
return tail(
|
108
|
-
};
|
109
|
-
container2.innerText = tail(0, end);
|
110
|
-
};
|
111
|
-
const middleTail = (leftPart, rightPart) => {
|
112
|
-
if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
113
|
-
return content.slice(0, leftPart[0]) + dots + content.slice(rightPart[1], end);
|
106
|
+
return tail(middle2, right);
|
114
107
|
}
|
115
|
-
|
116
|
-
|
117
|
-
container2.innerText = props.content.slice(0, leftMiddle) + props.dots + props.content.slice(rightMiddle, end) + props.expandText;
|
118
|
-
if (container2.offsetHeight >= maxHeight2) {
|
119
|
-
return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
|
108
|
+
if (position === "end") {
|
109
|
+
return tail(middle2, right);
|
120
110
|
}
|
121
|
-
return
|
111
|
+
return tail(left, middle2);
|
122
112
|
};
|
123
|
-
|
124
|
-
|
125
|
-
|
113
|
+
return tail(0, end);
|
114
|
+
};
|
115
|
+
const middleTail = (leftPart, rightPart) => {
|
116
|
+
if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
117
|
+
return content.slice(0, leftPart[0]) + dots + content.slice(rightPart[1], end);
|
118
|
+
}
|
119
|
+
const leftMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
120
|
+
const rightMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
121
|
+
container.innerText = props.content.slice(0, leftMiddle) + props.dots + props.content.slice(rightMiddle, end);
|
122
|
+
container.innerHTML += actionHTML;
|
123
|
+
if (container.offsetHeight >= maxHeight) {
|
124
|
+
return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
|
125
|
+
}
|
126
|
+
return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
|
126
127
|
};
|
128
|
+
return props.position === "middle" ? middleTail([0, middle], [middle, end]) : calcEllipse();
|
129
|
+
};
|
130
|
+
const calcEllipsised = () => {
|
127
131
|
const container = cloneContainer();
|
128
132
|
if (!container) {
|
129
133
|
needRecalculate = true;
|
@@ -156,11 +160,17 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
156
160
|
expanded: expanded.value
|
157
161
|
}) : actionText.value;
|
158
162
|
return (0, import_vue.createVNode)("span", {
|
163
|
+
"ref": actionRef,
|
159
164
|
"class": bem("action"),
|
160
165
|
"onClick": onClickAction
|
161
166
|
}, [action]);
|
162
167
|
};
|
163
|
-
(0, import_vue2.onMounted)(
|
168
|
+
(0, import_vue2.onMounted)(() => {
|
169
|
+
calcEllipsised();
|
170
|
+
if (slots.action) {
|
171
|
+
(0, import_vue2.nextTick)(calcEllipsised);
|
172
|
+
}
|
173
|
+
});
|
164
174
|
(0, import_vue2.onActivated)(() => {
|
165
175
|
if (needRecalculate) {
|
166
176
|
needRecalculate = false;
|
package/lib/uploader/Uploader.js
CHANGED
@@ -216,7 +216,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
216
216
|
emit("update:modelValue", fileList);
|
217
217
|
emit("delete", item, getDetail(index));
|
218
218
|
};
|
219
|
-
const
|
219
|
+
const reuploadFile = (index) => {
|
220
220
|
isReuploading.value = true;
|
221
221
|
reuploadIndex.value = index;
|
222
222
|
(0, import_vue2.nextTick)(() => chooseFile());
|
@@ -236,7 +236,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
236
236
|
"onClick": () => emit(props.reupload ? "clickReupload" : "clickPreview", item, getDetail(index)),
|
237
237
|
"onDelete": () => deleteFile(item, index),
|
238
238
|
"onPreview": () => previewImage(item),
|
239
|
-
"onReupload": () =>
|
239
|
+
"onReupload": () => reuploadFile(index)
|
240
240
|
}, (0, import_utils.pick)(props, ["name", "lazyLoad"]), previewData), (0, import_utils.pick)(slots, ["preview-cover", "preview-delete"]));
|
241
241
|
};
|
242
242
|
const renderPreviewList = () => {
|
@@ -246,10 +246,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
246
246
|
};
|
247
247
|
const onClickUpload = (event) => emit("clickUpload", event);
|
248
248
|
const renderUpload = () => {
|
249
|
-
|
250
|
-
return;
|
251
|
-
}
|
252
|
-
const hideUploader = props.modelValue.length >= +props.maxCount && props.reupload;
|
249
|
+
const lessThanMax = props.modelValue.length < +props.maxCount;
|
253
250
|
const Input = props.readonly ? null : (0, import_vue.createVNode)("input", {
|
254
251
|
"ref": inputRef,
|
255
252
|
"type": "file",
|
@@ -265,7 +262,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
265
262
|
return (0, import_vue.withDirectives)((0, import_vue.createVNode)("div", {
|
266
263
|
"class": (0, import_utils2.bem)("input-wrapper"),
|
267
264
|
"onClick": onClickUpload
|
268
|
-
}, [slots.default(), Input]), [[import_vue.vShow,
|
265
|
+
}, [slots.default(), Input]), [[import_vue.vShow, lessThanMax]]);
|
269
266
|
}
|
270
267
|
return (0, import_vue.withDirectives)((0, import_vue.createVNode)("div", {
|
271
268
|
"class": (0, import_utils2.bem)("upload", {
|
@@ -278,7 +275,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
278
275
|
"class": (0, import_utils2.bem)("upload-icon")
|
279
276
|
}, null), props.uploadText && (0, import_vue.createVNode)("span", {
|
280
277
|
"class": (0, import_utils2.bem)("upload-text")
|
281
|
-
}, [props.uploadText]), Input]), [[import_vue.vShow, props.showUpload &&
|
278
|
+
}, [props.uploadText]), Input]), [[import_vue.vShow, props.showUpload && lessThanMax]]);
|
282
279
|
};
|
283
280
|
const chooseFile = () => {
|
284
281
|
if (inputRef.value && !props.disabled) {
|
@@ -290,6 +287,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
290
287
|
});
|
291
288
|
(0, import_use_expose.useExpose)({
|
292
289
|
chooseFile,
|
290
|
+
reuploadFile,
|
293
291
|
closeImagePreview
|
294
292
|
});
|
295
293
|
(0, import_use.useCustomFieldValue)(() => props.modelValue);
|
package/lib/uploader/types.d.ts
CHANGED
@@ -29,6 +29,7 @@ export type UploaderAfterRead = (items: UploaderFileListItem | UploaderFileListI
|
|
29
29
|
export type UploaderExpose = {
|
30
30
|
chooseFile: () => void;
|
31
31
|
closeImagePreview: () => void;
|
32
|
+
reuploadFile: (index: number) => void;
|
32
33
|
};
|
33
34
|
export type UploaderInstance = ComponentPublicInstance<UploaderProps, UploaderExpose>;
|
34
35
|
export type UploaderThemeVars = {
|