vant 3.6.10 → 3.6.12
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/field/Field.mjs +38 -5
- package/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/es/uploader/Uploader.mjs +6 -4
- package/es/uploader/UploaderPreviewItem.mjs +1 -1
- package/es/uploader/types.d.ts +1 -0
- package/es/uploader/utils.mjs +1 -1
- package/lib/field/Field.js +38 -5
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/uploader/Uploader.js +6 -4
- package/lib/uploader/UploaderPreviewItem.js +1 -1
- package/lib/uploader/types.d.ts +1 -0
- package/lib/uploader/utils.js +1 -1
- package/lib/vant.cjs.js +47 -12
- package/lib/vant.es.js +47 -12
- package/lib/vant.js +47 -12
- package/lib/vant.min.js +1 -1
- package/lib/web-types.json +1785 -1785
- package/package.json +1 -1
package/lib/vant.js
CHANGED
@@ -3188,6 +3188,7 @@
|
|
3188
3188
|
}
|
3189
3189
|
};
|
3190
3190
|
const limitValueLength = (value) => {
|
3191
|
+
var _a;
|
3191
3192
|
const {
|
3192
3193
|
maxlength
|
3193
3194
|
} = props;
|
@@ -3196,6 +3197,13 @@
|
|
3196
3197
|
if (modelValue && getStringLength(modelValue) === +maxlength) {
|
3197
3198
|
return modelValue;
|
3198
3199
|
}
|
3200
|
+
const selectionEnd = (_a = inputRef.value) == null ? void 0 : _a.selectionEnd;
|
3201
|
+
if (state.focused && selectionEnd) {
|
3202
|
+
const valueArr = [...value];
|
3203
|
+
const exceededLength = valueArr.length - +maxlength;
|
3204
|
+
valueArr.splice(selectionEnd - exceededLength, exceededLength);
|
3205
|
+
return valueArr.join("");
|
3206
|
+
}
|
3199
3207
|
return cutString(value, +maxlength);
|
3200
3208
|
}
|
3201
3209
|
return value;
|
@@ -3203,22 +3211,47 @@
|
|
3203
3211
|
const updateValue = (value, trigger = "onChange") => {
|
3204
3212
|
const originalValue = value;
|
3205
3213
|
value = limitValueLength(value);
|
3206
|
-
const
|
3214
|
+
const limitDiffLen = getStringLength(originalValue) - getStringLength(value);
|
3207
3215
|
if (props.type === "number" || props.type === "digit") {
|
3208
3216
|
const isNumber = props.type === "number";
|
3209
3217
|
value = formatNumber(value, isNumber, isNumber);
|
3210
3218
|
}
|
3219
|
+
let formatterDiffLen = 0;
|
3211
3220
|
if (props.formatter && trigger === props.formatTrigger) {
|
3212
|
-
|
3221
|
+
const {
|
3222
|
+
formatter,
|
3223
|
+
maxlength
|
3224
|
+
} = props;
|
3225
|
+
value = formatter(value);
|
3226
|
+
if (isDef(maxlength) && getStringLength(value) > maxlength) {
|
3227
|
+
value = cutString(value, +maxlength);
|
3228
|
+
}
|
3229
|
+
if (inputRef.value && state.focused) {
|
3230
|
+
const {
|
3231
|
+
selectionEnd
|
3232
|
+
} = inputRef.value;
|
3233
|
+
const bcoVal = cutString(originalValue, selectionEnd);
|
3234
|
+
formatterDiffLen = getStringLength(formatter(bcoVal)) - getStringLength(bcoVal);
|
3235
|
+
}
|
3213
3236
|
}
|
3214
3237
|
if (inputRef.value && inputRef.value.value !== value) {
|
3215
|
-
if (state.focused
|
3216
|
-
|
3238
|
+
if (state.focused) {
|
3239
|
+
let {
|
3217
3240
|
selectionStart,
|
3218
3241
|
selectionEnd
|
3219
3242
|
} = inputRef.value;
|
3220
3243
|
inputRef.value.value = value;
|
3221
|
-
|
3244
|
+
if (isDef(selectionStart) && isDef(selectionEnd)) {
|
3245
|
+
const valueLen = getStringLength(value);
|
3246
|
+
if (limitDiffLen) {
|
3247
|
+
selectionStart -= limitDiffLen;
|
3248
|
+
selectionEnd -= limitDiffLen;
|
3249
|
+
} else if (formatterDiffLen) {
|
3250
|
+
selectionStart += formatterDiffLen;
|
3251
|
+
selectionEnd += formatterDiffLen;
|
3252
|
+
}
|
3253
|
+
inputRef.value.setSelectionRange(Math.min(selectionStart, valueLen), Math.min(selectionEnd, valueLen));
|
3254
|
+
}
|
3222
3255
|
} else {
|
3223
3256
|
inputRef.value.value = value;
|
3224
3257
|
}
|
@@ -14912,7 +14945,7 @@
|
|
14912
14945
|
});
|
14913
14946
|
return { valid, invalid };
|
14914
14947
|
}
|
14915
|
-
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
|
14948
|
+
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg|avif)/i;
|
14916
14949
|
const isImageUrl = (url) => IMAGE_REGEXP.test(url);
|
14917
14950
|
function isImageFile(item) {
|
14918
14951
|
if (item.isImage) {
|
@@ -15022,7 +15055,7 @@
|
|
15022
15055
|
if (isImageFile(item)) {
|
15023
15056
|
return vue.createVNode(Image$1, {
|
15024
15057
|
"fit": imageFit,
|
15025
|
-
"src": item.content || item.url,
|
15058
|
+
"src": item.objectUrl || item.content || item.url,
|
15026
15059
|
"class": bem("preview-image"),
|
15027
15060
|
"width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
|
15028
15061
|
"height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
|
@@ -15131,7 +15164,8 @@
|
|
15131
15164
|
const result = {
|
15132
15165
|
file,
|
15133
15166
|
status: "",
|
15134
|
-
message: ""
|
15167
|
+
message: "",
|
15168
|
+
objectUrl: URL.createObjectURL(file)
|
15135
15169
|
};
|
15136
15170
|
if (contents[index]) {
|
15137
15171
|
result.content = contents[index];
|
@@ -15145,7 +15179,8 @@
|
|
15145
15179
|
const result = {
|
15146
15180
|
file: files,
|
15147
15181
|
status: "",
|
15148
|
-
message: ""
|
15182
|
+
message: "",
|
15183
|
+
objectUrl: URL.createObjectURL(files)
|
15149
15184
|
};
|
15150
15185
|
if (content) {
|
15151
15186
|
result.content = content;
|
@@ -15187,8 +15222,8 @@
|
|
15187
15222
|
if (props.previewFullImage) {
|
15188
15223
|
const imageFiles = props.modelValue.filter(isImageFile);
|
15189
15224
|
const images = imageFiles.map((item2) => {
|
15190
|
-
if (item2.
|
15191
|
-
item2.url =
|
15225
|
+
if (item2.objectUrl && !item2.url && item2.status !== "failed") {
|
15226
|
+
item2.url = item2.objectUrl;
|
15192
15227
|
urls.push(item2.url);
|
15193
15228
|
}
|
15194
15229
|
return item2.url;
|
@@ -16164,7 +16199,7 @@
|
|
16164
16199
|
});
|
16165
16200
|
}
|
16166
16201
|
};
|
16167
|
-
const version = "3.6.
|
16202
|
+
const version = "3.6.12";
|
16168
16203
|
function install(app) {
|
16169
16204
|
const components = [
|
16170
16205
|
ActionBar,
|