Comparing version 3.6.10 to 3.6.11
@@ -94,2 +94,2 @@ export * from "./action-bar"; | ||
export function install(app: any): void; | ||
export const version: "3.6.10"; | ||
export const version: "3.6.11"; |
@@ -204,2 +204,3 @@ var __defProp = Object.defineProperty; | ||
const limitValueLength = (value) => { | ||
var _a; | ||
const { | ||
@@ -213,2 +214,9 @@ maxlength | ||
} | ||
const selectionEnd = (_a = inputRef.value) == null ? void 0 : _a.selectionEnd; | ||
if (state.focused && selectionEnd) { | ||
const valueArr = [...value]; | ||
const exceededLength = valueArr.length - +maxlength; | ||
valueArr.splice(selectionEnd - exceededLength, exceededLength); | ||
return valueArr.join(""); | ||
} | ||
return (0, import_utils2.cutString)(value, +maxlength); | ||
@@ -221,3 +229,3 @@ } | ||
value = limitValueLength(value); | ||
const isExceedLimit = value !== originalValue; | ||
const limitDiffLen = (0, import_utils2.getStringLength)(originalValue) - (0, import_utils2.getStringLength)(value); | ||
if (props.type === "number" || props.type === "digit") { | ||
@@ -227,8 +235,23 @@ const isNumber = props.type === "number"; | ||
} | ||
let formatterDiffLen = 0; | ||
if (props.formatter && trigger === props.formatTrigger) { | ||
value = props.formatter(value); | ||
const { | ||
formatter, | ||
maxlength | ||
} = props; | ||
value = formatter(value); | ||
if ((0, import_utils.isDef)(maxlength) && (0, import_utils2.getStringLength)(value) > maxlength) { | ||
value = (0, import_utils2.cutString)(value, +maxlength); | ||
} | ||
if (inputRef.value && state.focused) { | ||
const { | ||
selectionEnd | ||
} = inputRef.value; | ||
const bcoVal = (0, import_utils2.cutString)(originalValue, selectionEnd); | ||
formatterDiffLen = (0, import_utils2.getStringLength)(formatter(bcoVal)) - (0, import_utils2.getStringLength)(bcoVal); | ||
} | ||
} | ||
if (inputRef.value && inputRef.value.value !== value) { | ||
if (state.focused && isExceedLimit) { | ||
const { | ||
if (state.focused) { | ||
let { | ||
selectionStart, | ||
@@ -238,3 +261,13 @@ selectionEnd | ||
inputRef.value.value = value; | ||
inputRef.value.setSelectionRange(selectionStart - 1, selectionEnd - 1); | ||
if ((0, import_utils.isDef)(selectionStart) && (0, import_utils.isDef)(selectionEnd)) { | ||
const valueLen = (0, import_utils2.getStringLength)(value); | ||
if (limitDiffLen) { | ||
selectionStart -= limitDiffLen; | ||
selectionEnd -= limitDiffLen; | ||
} else if (formatterDiffLen) { | ||
selectionStart += formatterDiffLen; | ||
selectionEnd += formatterDiffLen; | ||
} | ||
inputRef.value.setSelectionRange(Math.min(selectionStart, valueLen), Math.min(selectionEnd, valueLen)); | ||
} | ||
} else { | ||
@@ -241,0 +274,0 @@ inputRef.value.value = value; |
@@ -94,2 +94,2 @@ export * from "./action-bar"; | ||
export function install(app: any): void; | ||
export const version: "3.6.10"; | ||
export const version: "3.6.11"; |
@@ -199,3 +199,3 @@ var __defProp = Object.defineProperty; | ||
__reExport(stdin_exports, require("./uploader"), module.exports); | ||
const version = "3.6.10"; | ||
const version = "3.6.11"; | ||
function install(app) { | ||
@@ -202,0 +202,0 @@ const components = [ |
{ | ||
"name": "vant", | ||
"version": "3.6.10", | ||
"version": "3.6.11", | ||
"description": "Lightweight Mobile UI Components built on Vue", | ||
@@ -5,0 +5,0 @@ "main": "lib/vant.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5583098
142254