first commit

This commit is contained in:
2025-12-29 14:59:44 +08:00
commit 10c3fbb0d7
5315 changed files with 795443 additions and 0 deletions

383
node_modules/vant/lib/field/Field.d.ts generated vendored Normal file
View File

@@ -0,0 +1,383 @@
import { type PropType, type ExtractPropTypes, type HTMLAttributes } from 'vue';
import type { FieldRule, FieldType, FieldTextAlign, FieldClearTrigger, FieldFormatTrigger, FieldAutosizeConfig } from './types';
export declare const fieldSharedProps: {
id: StringConstructor;
name: StringConstructor;
leftIcon: StringConstructor;
rightIcon: StringConstructor;
autofocus: BooleanConstructor;
clearable: BooleanConstructor;
maxlength: (NumberConstructor | StringConstructor)[];
max: NumberConstructor;
min: NumberConstructor;
formatter: PropType<(value: string) => string>;
clearIcon: {
type: PropType<string>;
default: string;
};
modelValue: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
inputAlign: PropType<FieldTextAlign>;
placeholder: StringConstructor;
autocomplete: StringConstructor;
autocapitalize: StringConstructor;
autocorrect: StringConstructor;
errorMessage: StringConstructor;
enterkeyhint: StringConstructor;
clearTrigger: {
type: PropType<FieldClearTrigger>;
default: FieldClearTrigger;
};
formatTrigger: {
type: PropType<FieldFormatTrigger>;
default: FieldFormatTrigger;
};
spellcheck: {
type: BooleanConstructor;
default: null;
};
error: {
type: BooleanConstructor;
default: null;
};
disabled: {
type: BooleanConstructor;
default: null;
};
readonly: {
type: BooleanConstructor;
default: null;
};
inputmode: PropType<HTMLAttributes["inputmode"]>;
};
export declare const fieldProps: {
tag: {
type: PropType<keyof HTMLElementTagNameMap>;
default: keyof HTMLElementTagNameMap;
};
icon: StringConstructor;
size: PropType<import("../cell").CellSize>;
title: (NumberConstructor | StringConstructor)[];
value: (NumberConstructor | StringConstructor)[];
label: (NumberConstructor | StringConstructor)[];
center: BooleanConstructor;
isLink: BooleanConstructor;
border: {
type: BooleanConstructor;
default: true;
};
iconPrefix: StringConstructor;
valueClass: PropType<unknown>;
labelClass: PropType<unknown>;
titleClass: PropType<unknown>;
titleStyle: PropType<string | import("vue").CSSProperties>;
arrowDirection: PropType<import("../cell").CellArrowDirection>;
required: {
type: PropType<boolean | "auto">;
default: null;
};
clickable: {
type: PropType<boolean | null>;
default: null;
};
} & {
id: StringConstructor;
name: StringConstructor;
leftIcon: StringConstructor;
rightIcon: StringConstructor;
autofocus: BooleanConstructor;
clearable: BooleanConstructor;
maxlength: (NumberConstructor | StringConstructor)[];
max: NumberConstructor;
min: NumberConstructor;
formatter: PropType<(value: string) => string>;
clearIcon: {
type: PropType<string>;
default: string;
};
modelValue: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
inputAlign: PropType<FieldTextAlign>;
placeholder: StringConstructor;
autocomplete: StringConstructor;
autocapitalize: StringConstructor;
autocorrect: StringConstructor;
errorMessage: StringConstructor;
enterkeyhint: StringConstructor;
clearTrigger: {
type: PropType<FieldClearTrigger>;
default: FieldClearTrigger;
};
formatTrigger: {
type: PropType<FieldFormatTrigger>;
default: FieldFormatTrigger;
};
spellcheck: {
type: BooleanConstructor;
default: null;
};
error: {
type: BooleanConstructor;
default: null;
};
disabled: {
type: BooleanConstructor;
default: null;
};
readonly: {
type: BooleanConstructor;
default: null;
};
inputmode: PropType<HTMLAttributes["inputmode"]>;
} & {
rows: (NumberConstructor | StringConstructor)[];
type: {
type: PropType<FieldType>;
default: FieldType;
};
rules: PropType<FieldRule[]>;
autosize: PropType<boolean | FieldAutosizeConfig>;
labelWidth: (NumberConstructor | StringConstructor)[];
labelClass: PropType<unknown>;
labelAlign: PropType<FieldTextAlign>;
showWordLimit: BooleanConstructor;
errorMessageAlign: PropType<FieldTextAlign>;
colon: {
type: BooleanConstructor;
default: null;
};
};
export type FieldProps = ExtractPropTypes<typeof fieldProps>;
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
tag: {
type: PropType<keyof HTMLElementTagNameMap>;
default: keyof HTMLElementTagNameMap;
};
icon: StringConstructor;
size: PropType<import("../cell").CellSize>;
title: (NumberConstructor | StringConstructor)[];
value: (NumberConstructor | StringConstructor)[];
label: (NumberConstructor | StringConstructor)[];
center: BooleanConstructor;
isLink: BooleanConstructor;
border: {
type: BooleanConstructor;
default: true;
};
iconPrefix: StringConstructor;
valueClass: PropType<unknown>;
labelClass: PropType<unknown>;
titleClass: PropType<unknown>;
titleStyle: PropType<string | import("vue").CSSProperties>;
arrowDirection: PropType<import("../cell").CellArrowDirection>;
required: {
type: PropType<boolean | "auto">;
default: null;
};
clickable: {
type: PropType<boolean | null>;
default: null;
};
} & {
id: StringConstructor;
name: StringConstructor;
leftIcon: StringConstructor;
rightIcon: StringConstructor;
autofocus: BooleanConstructor;
clearable: BooleanConstructor;
maxlength: (NumberConstructor | StringConstructor)[];
max: NumberConstructor;
min: NumberConstructor;
formatter: PropType<(value: string) => string>;
clearIcon: {
type: PropType<string>;
default: string;
};
modelValue: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
inputAlign: PropType<FieldTextAlign>;
placeholder: StringConstructor;
autocomplete: StringConstructor;
autocapitalize: StringConstructor;
autocorrect: StringConstructor;
errorMessage: StringConstructor;
enterkeyhint: StringConstructor;
clearTrigger: {
type: PropType<FieldClearTrigger>;
default: FieldClearTrigger;
};
formatTrigger: {
type: PropType<FieldFormatTrigger>;
default: FieldFormatTrigger;
};
spellcheck: {
type: BooleanConstructor;
default: null;
};
error: {
type: BooleanConstructor;
default: null;
};
disabled: {
type: BooleanConstructor;
default: null;
};
readonly: {
type: BooleanConstructor;
default: null;
};
inputmode: PropType<HTMLAttributes["inputmode"]>;
} & {
rows: (NumberConstructor | StringConstructor)[];
type: {
type: PropType<FieldType>;
default: FieldType;
};
rules: PropType<FieldRule[]>;
autosize: PropType<boolean | FieldAutosizeConfig>;
labelWidth: (NumberConstructor | StringConstructor)[];
labelClass: PropType<unknown>;
labelAlign: PropType<FieldTextAlign>;
showWordLimit: BooleanConstructor;
errorMessageAlign: PropType<FieldTextAlign>;
colon: {
type: BooleanConstructor;
default: null;
};
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("clear" | "focus" | "blur" | "keypress" | "clickInput" | "endValidate" | "startValidate" | "clickLeftIcon" | "clickRightIcon" | "update:modelValue")[], "clear" | "focus" | "blur" | "keypress" | "clickInput" | "endValidate" | "startValidate" | "clickLeftIcon" | "clickRightIcon" | "update:modelValue", import("vue").PublicProps, Readonly<ExtractPropTypes<{
tag: {
type: PropType<keyof HTMLElementTagNameMap>;
default: keyof HTMLElementTagNameMap;
};
icon: StringConstructor;
size: PropType<import("../cell").CellSize>;
title: (NumberConstructor | StringConstructor)[];
value: (NumberConstructor | StringConstructor)[];
label: (NumberConstructor | StringConstructor)[];
center: BooleanConstructor;
isLink: BooleanConstructor;
border: {
type: BooleanConstructor;
default: true;
};
iconPrefix: StringConstructor;
valueClass: PropType<unknown>;
labelClass: PropType<unknown>;
titleClass: PropType<unknown>;
titleStyle: PropType<string | import("vue").CSSProperties>;
arrowDirection: PropType<import("../cell").CellArrowDirection>;
required: {
type: PropType<boolean | "auto">;
default: null;
};
clickable: {
type: PropType<boolean | null>;
default: null;
};
} & {
id: StringConstructor;
name: StringConstructor;
leftIcon: StringConstructor;
rightIcon: StringConstructor;
autofocus: BooleanConstructor;
clearable: BooleanConstructor;
maxlength: (NumberConstructor | StringConstructor)[];
max: NumberConstructor;
min: NumberConstructor;
formatter: PropType<(value: string) => string>;
clearIcon: {
type: PropType<string>;
default: string;
};
modelValue: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
inputAlign: PropType<FieldTextAlign>;
placeholder: StringConstructor;
autocomplete: StringConstructor;
autocapitalize: StringConstructor;
autocorrect: StringConstructor;
errorMessage: StringConstructor;
enterkeyhint: StringConstructor;
clearTrigger: {
type: PropType<FieldClearTrigger>;
default: FieldClearTrigger;
};
formatTrigger: {
type: PropType<FieldFormatTrigger>;
default: FieldFormatTrigger;
};
spellcheck: {
type: BooleanConstructor;
default: null;
};
error: {
type: BooleanConstructor;
default: null;
};
disabled: {
type: BooleanConstructor;
default: null;
};
readonly: {
type: BooleanConstructor;
default: null;
};
inputmode: PropType<HTMLAttributes["inputmode"]>;
} & {
rows: (NumberConstructor | StringConstructor)[];
type: {
type: PropType<FieldType>;
default: FieldType;
};
rules: PropType<FieldRule[]>;
autosize: PropType<boolean | FieldAutosizeConfig>;
labelWidth: (NumberConstructor | StringConstructor)[];
labelClass: PropType<unknown>;
labelAlign: PropType<FieldTextAlign>;
showWordLimit: BooleanConstructor;
errorMessageAlign: PropType<FieldTextAlign>;
colon: {
type: BooleanConstructor;
default: null;
};
}>> & Readonly<{
onFocus?: ((...args: any[]) => any) | undefined;
onBlur?: ((...args: any[]) => any) | undefined;
onKeypress?: ((...args: any[]) => any) | undefined;
onClear?: ((...args: any[]) => any) | undefined;
onClickInput?: ((...args: any[]) => any) | undefined;
onEndValidate?: ((...args: any[]) => any) | undefined;
onStartValidate?: ((...args: any[]) => any) | undefined;
onClickLeftIcon?: ((...args: any[]) => any) | undefined;
onClickRightIcon?: ((...args: any[]) => any) | undefined;
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
}>, {
type: FieldType;
tag: keyof HTMLElementTagNameMap;
center: boolean;
autofocus: boolean;
disabled: boolean;
border: boolean;
isLink: boolean;
required: boolean | "auto";
clickable: boolean | null;
clearable: boolean;
clearIcon: string;
modelValue: string | number;
clearTrigger: FieldClearTrigger;
formatTrigger: FieldFormatTrigger;
spellcheck: boolean;
error: boolean;
readonly: boolean;
showWordLimit: boolean;
colon: boolean;
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
export default _default;

569
node_modules/vant/lib/field/Field.js generated vendored Normal file
View File

@@ -0,0 +1,569 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name2 in all)
__defProp(target, name2, { get: all[name2], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
default: () => stdin_default,
fieldProps: () => fieldProps,
fieldSharedProps: () => fieldSharedProps
});
module.exports = __toCommonJS(stdin_exports);
var import_vue = require("vue");
var import_utils = require("../utils");
var import_utils2 = require("./utils");
var import_Cell = require("../cell/Cell");
var import_use = require("@vant/use");
var import_use_id = require("../composables/use-id");
var import_use_expose = require("../composables/use-expose");
var import_icon = require("../icon");
var import_cell = require("../cell");
const [name, bem] = (0, import_utils.createNamespace)("field");
const fieldSharedProps = {
id: String,
name: String,
leftIcon: String,
rightIcon: String,
autofocus: Boolean,
clearable: Boolean,
maxlength: import_utils.numericProp,
max: Number,
min: Number,
formatter: Function,
clearIcon: (0, import_utils.makeStringProp)("clear"),
modelValue: (0, import_utils.makeNumericProp)(""),
inputAlign: String,
placeholder: String,
autocomplete: String,
autocapitalize: String,
autocorrect: String,
errorMessage: String,
enterkeyhint: String,
clearTrigger: (0, import_utils.makeStringProp)("focus"),
formatTrigger: (0, import_utils.makeStringProp)("onChange"),
spellcheck: {
type: Boolean,
default: null
},
error: {
type: Boolean,
default: null
},
disabled: {
type: Boolean,
default: null
},
readonly: {
type: Boolean,
default: null
},
inputmode: String
};
const fieldProps = (0, import_utils.extend)({}, import_Cell.cellSharedProps, fieldSharedProps, {
rows: import_utils.numericProp,
type: (0, import_utils.makeStringProp)("text"),
rules: Array,
autosize: [Boolean, Object],
labelWidth: import_utils.numericProp,
labelClass: import_utils.unknownProp,
labelAlign: String,
showWordLimit: Boolean,
errorMessageAlign: String,
colon: {
type: Boolean,
default: null
}
});
var stdin_default = (0, import_vue.defineComponent)({
name,
props: fieldProps,
emits: ["blur", "focus", "clear", "keypress", "clickInput", "endValidate", "startValidate", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
setup(props, {
emit,
slots
}) {
const id = (0, import_use_id.useId)();
const state = (0, import_vue.reactive)({
status: "unvalidated",
focused: false,
validateMessage: ""
});
const inputRef = (0, import_vue.ref)();
const clearIconRef = (0, import_vue.ref)();
const customValue = (0, import_vue.ref)();
const {
parent: form
} = (0, import_use.useParent)(import_utils.FORM_KEY);
const getModelValue = () => {
var _a;
return String((_a = props.modelValue) != null ? _a : "");
};
const getProp = (key) => {
if ((0, import_utils.isDef)(props[key])) {
return props[key];
}
if (form && (0, import_utils.isDef)(form.props[key])) {
return form.props[key];
}
};
const showClear = (0, import_vue.computed)(() => {
const readonly = getProp("readonly");
if (props.clearable && !readonly) {
const hasValue = getModelValue() !== "";
const trigger = props.clearTrigger === "always" || props.clearTrigger === "focus" && state.focused;
return hasValue && trigger;
}
return false;
});
const formValue = (0, import_vue.computed)(() => {
if (customValue.value && slots.input) {
return customValue.value();
}
return props.modelValue;
});
const showRequiredMark = (0, import_vue.computed)(() => {
var _a;
const required = getProp("required");
if (required === "auto") {
return (_a = props.rules) == null ? void 0 : _a.some((rule) => rule.required);
}
return required;
});
const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
if (state.status === "failed") {
return;
}
let {
value
} = formValue;
if (rule.formatter) {
value = rule.formatter(value, rule);
}
if (!(0, import_utils2.runSyncRule)(value, rule)) {
state.status = "failed";
state.validateMessage = (0, import_utils2.getRuleMessage)(value, rule);
return;
}
if (rule.validator) {
if ((0, import_utils2.isEmptyValue)(value) && rule.validateEmpty === false) {
return;
}
return (0, import_utils2.runRuleValidator)(value, rule).then((result) => {
if (result && typeof result === "string") {
state.status = "failed";
state.validateMessage = result;
} else if (result === false) {
state.status = "failed";
state.validateMessage = (0, import_utils2.getRuleMessage)(value, rule);
}
});
}
}), Promise.resolve());
const resetValidation = () => {
state.status = "unvalidated";
state.validateMessage = "";
};
const endValidate = () => emit("endValidate", {
status: state.status,
message: state.validateMessage
});
const validate = (rules = props.rules) => new Promise((resolve) => {
resetValidation();
if (rules) {
emit("startValidate");
runRules(rules).then(() => {
if (state.status === "failed") {
resolve({
name: props.name,
message: state.validateMessage
});
endValidate();
} else {
state.status = "passed";
resolve();
endValidate();
}
});
} else {
resolve();
}
});
const validateWithTrigger = (trigger) => {
if (form && props.rules) {
const {
validateTrigger
} = form.props;
const defaultTrigger = (0, import_utils.toArray)(validateTrigger).includes(trigger);
const rules = props.rules.filter((rule) => {
if (rule.trigger) {
return (0, import_utils.toArray)(rule.trigger).includes(trigger);
}
return defaultTrigger;
});
if (rules.length) {
validate(rules);
}
}
};
const limitValueLength = (value) => {
var _a;
const {
maxlength
} = props;
if ((0, import_utils.isDef)(maxlength) && (0, import_utils2.getStringLength)(value) > +maxlength) {
const modelValue = getModelValue();
if (modelValue && (0, import_utils2.getStringLength)(modelValue) === +maxlength) {
return modelValue;
}
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);
}
return value;
};
const updateValue = (value, trigger = "onChange") => {
var _a, _b;
const originalValue = value;
value = limitValueLength(value);
const limitDiffLen = (0, import_utils2.getStringLength)(originalValue) - (0, import_utils2.getStringLength)(value);
if (props.type === "number" || props.type === "digit") {
const isNumber = props.type === "number";
value = (0, import_utils.formatNumber)(value, isNumber, isNumber);
if (trigger === "onBlur" && value !== "" && (props.min !== void 0 || props.max !== void 0)) {
const adjustedValue = (0, import_utils.clamp)(+value, (_a = props.min) != null ? _a : -Infinity, (_b = props.max) != null ? _b : Infinity);
if (+value !== adjustedValue) {
value = adjustedValue.toString();
}
}
}
let formatterDiffLen = 0;
if (props.formatter && trigger === props.formatTrigger) {
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) {
let {
selectionStart,
selectionEnd
} = inputRef.value;
inputRef.value.value = value;
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 {
inputRef.value.value = value;
}
}
if (value !== props.modelValue) {
emit("update:modelValue", value);
}
};
const onInput = (event) => {
if (!event.target.composing) {
updateValue(event.target.value);
}
};
const blur = () => {
var _a;
return (_a = inputRef.value) == null ? void 0 : _a.blur();
};
const focus = () => {
var _a;
return (_a = inputRef.value) == null ? void 0 : _a.focus();
};
const adjustTextareaSize = () => {
const input = inputRef.value;
if (props.type === "textarea" && props.autosize && input) {
(0, import_utils2.resizeTextarea)(input, props.autosize);
}
};
const onFocus = (event) => {
state.focused = true;
emit("focus", event);
(0, import_vue.nextTick)(adjustTextareaSize);
if (getProp("readonly")) {
blur();
}
};
const onBlur = (event) => {
state.focused = false;
updateValue(getModelValue(), "onBlur");
emit("blur", event);
if (getProp("readonly")) {
return;
}
validateWithTrigger("onBlur");
(0, import_vue.nextTick)(adjustTextareaSize);
(0, import_utils.resetScroll)();
};
const onClickInput = (event) => emit("clickInput", event);
const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
const onClickRightIcon = (event) => emit("clickRightIcon", event);
const onClear = (event) => {
(0, import_utils.preventDefault)(event);
emit("update:modelValue", "");
emit("clear", event);
};
const showError = (0, import_vue.computed)(() => {
if (typeof props.error === "boolean") {
return props.error;
}
if (form && form.props.showError && state.status === "failed") {
return true;
}
});
const labelStyle = (0, import_vue.computed)(() => {
const labelWidth = getProp("labelWidth");
const labelAlign = getProp("labelAlign");
if (labelWidth && labelAlign !== "top") {
return {
width: (0, import_utils.addUnit)(labelWidth)
};
}
});
const onKeypress = (event) => {
const ENTER_CODE = 13;
if (event.keyCode === ENTER_CODE) {
const submitOnEnter = form && form.props.submitOnEnter;
if (!submitOnEnter && props.type !== "textarea") {
(0, import_utils.preventDefault)(event);
}
if (props.type === "search") {
blur();
}
}
emit("keypress", event);
};
const getInputId = () => props.id || `${id}-input`;
const getValidationStatus = () => state.status;
const renderInput = () => {
const controlClass = bem("control", [getProp("inputAlign"), {
error: showError.value,
custom: !!slots.input,
"min-height": props.type === "textarea" && !props.autosize
}]);
if (slots.input) {
return (0, import_vue.createVNode)("div", {
"class": controlClass,
"onClick": onClickInput
}, [slots.input()]);
}
const inputAttrs = {
id: getInputId(),
ref: inputRef,
name: props.name,
rows: props.rows !== void 0 ? +props.rows : void 0,
class: controlClass,
disabled: getProp("disabled"),
readonly: getProp("readonly"),
autofocus: props.autofocus,
placeholder: props.placeholder,
autocomplete: props.autocomplete,
autocapitalize: props.autocapitalize,
autocorrect: props.autocorrect,
enterkeyhint: props.enterkeyhint,
spellcheck: props.spellcheck,
"aria-labelledby": props.label ? `${id}-label` : void 0,
"data-allow-mismatch": "attribute",
onBlur,
onFocus,
onInput,
onClick: onClickInput,
onChange: import_utils2.endComposing,
onKeypress,
onCompositionend: import_utils2.endComposing,
onCompositionstart: import_utils2.startComposing
};
if (props.type === "textarea") {
return (0, import_vue.createVNode)("textarea", (0, import_vue.mergeProps)(inputAttrs, {
"inputmode": props.inputmode
}), null);
}
return (0, import_vue.createVNode)("input", (0, import_vue.mergeProps)((0, import_utils2.mapInputType)(props.type, props.inputmode), inputAttrs), null);
};
const renderLeftIcon = () => {
const leftIconSlot = slots["left-icon"];
if (props.leftIcon || leftIconSlot) {
return (0, import_vue.createVNode)("div", {
"class": bem("left-icon"),
"onClick": onClickLeftIcon
}, [leftIconSlot ? leftIconSlot() : (0, import_vue.createVNode)(import_icon.Icon, {
"name": props.leftIcon,
"classPrefix": props.iconPrefix
}, null)]);
}
};
const renderRightIcon = () => {
const rightIconSlot = slots["right-icon"];
if (props.rightIcon || rightIconSlot) {
return (0, import_vue.createVNode)("div", {
"class": bem("right-icon"),
"onClick": onClickRightIcon
}, [rightIconSlot ? rightIconSlot() : (0, import_vue.createVNode)(import_icon.Icon, {
"name": props.rightIcon,
"classPrefix": props.iconPrefix
}, null)]);
}
};
const renderWordLimit = () => {
if (props.showWordLimit && props.maxlength) {
const count = (0, import_utils2.getStringLength)(getModelValue());
return (0, import_vue.createVNode)("div", {
"class": bem("word-limit")
}, [(0, import_vue.createVNode)("span", {
"class": bem("word-num")
}, [count]), (0, import_vue.createTextVNode)("/"), props.maxlength]);
}
};
const renderMessage = () => {
if (form && form.props.showErrorMessage === false) {
return;
}
const message = props.errorMessage || state.validateMessage;
if (message) {
const slot = slots["error-message"];
const errorMessageAlign = getProp("errorMessageAlign");
return (0, import_vue.createVNode)("div", {
"class": bem("error-message", errorMessageAlign)
}, [slot ? slot({
message
}) : message]);
}
};
const renderLabel = () => {
const labelWidth = getProp("labelWidth");
const labelAlign = getProp("labelAlign");
const colon = getProp("colon") ? ":" : "";
if (slots.label) {
return [slots.label(), colon];
}
if (props.label) {
return (0, import_vue.createVNode)("label", {
"id": `${id}-label`,
"for": slots.input ? void 0 : getInputId(),
"data-allow-mismatch": "attribute",
"onClick": (event) => {
(0, import_utils.preventDefault)(event);
focus();
},
"style": labelAlign === "top" && labelWidth ? {
width: (0, import_utils.addUnit)(labelWidth)
} : void 0
}, [props.label + colon]);
}
};
const renderFieldBody = () => [(0, import_vue.createVNode)("div", {
"class": bem("body")
}, [renderInput(), showClear.value && (0, import_vue.createVNode)(import_icon.Icon, {
"ref": clearIconRef,
"name": props.clearIcon,
"class": bem("clear")
}, null), renderRightIcon(), slots.button && (0, import_vue.createVNode)("div", {
"class": bem("button")
}, [slots.button()])]), renderWordLimit(), renderMessage()];
(0, import_use_expose.useExpose)({
blur,
focus,
validate,
formValue,
resetValidation,
getValidationStatus
});
(0, import_vue.provide)(import_use.CUSTOM_FIELD_INJECTION_KEY, {
customValue,
resetValidation,
validateWithTrigger
});
(0, import_vue.watch)(() => props.modelValue, () => {
updateValue(getModelValue());
resetValidation();
validateWithTrigger("onChange");
(0, import_vue.nextTick)(adjustTextareaSize);
});
(0, import_vue.onMounted)(() => {
updateValue(getModelValue(), props.formatTrigger);
(0, import_vue.nextTick)(adjustTextareaSize);
});
(0, import_use.useEventListener)("touchstart", onClear, {
target: (0, import_vue.computed)(() => {
var _a;
return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
})
});
return () => {
const disabled = getProp("disabled");
const labelAlign = getProp("labelAlign");
const LeftIcon = renderLeftIcon();
const renderTitle = () => {
const Label = renderLabel();
if (labelAlign === "top") {
return [LeftIcon, Label].filter(Boolean);
}
return Label || [];
};
return (0, import_vue.createVNode)(import_cell.Cell, {
"size": props.size,
"class": bem({
error: showError.value,
disabled,
[`label-${labelAlign}`]: labelAlign
}),
"center": props.center,
"border": props.border,
"isLink": props.isLink,
"clickable": props.clickable,
"titleStyle": labelStyle.value,
"valueClass": bem("value"),
"titleClass": [bem("label", [labelAlign, {
required: showRequiredMark.value
}]), props.labelClass],
"arrowDirection": props.arrowDirection
}, {
icon: LeftIcon && labelAlign !== "top" ? () => LeftIcon : null,
title: renderTitle,
value: renderFieldBody,
extra: slots.extra
});
};
}
});

1
node_modules/vant/lib/field/index.css generated vendored Normal file
View File

@@ -0,0 +1 @@
:root,:host{--van-field-label-width: 6.2em;--van-field-label-color: var(--van-text-color);--van-field-label-margin-right: var(--van-padding-sm);--van-field-input-text-color: var(--van-text-color);--van-field-input-error-text-color: var(--van-danger-color);--van-field-input-disabled-text-color: var(--van-text-color-3);--van-field-placeholder-text-color: var(--van-text-color-3);--van-field-icon-size: 18px;--van-field-clear-icon-size: 18px;--van-field-clear-icon-color: var(--van-gray-5);--van-field-right-icon-color: var(--van-gray-6);--van-field-error-message-color: var(--van-danger-color);--van-field-error-message-font-size: 12px;--van-field-text-area-min-height: 60px;--van-field-word-limit-color: var(--van-gray-7);--van-field-word-limit-font-size: var(--van-font-size-sm);--van-field-word-limit-line-height: 16px;--van-field-disabled-text-color: var(--van-text-color-3);--van-field-required-mark-color: var(--van-red)}.van-field{flex-wrap:wrap}.van-field__label{flex:none;box-sizing:border-box;width:var(--van-field-label-width);margin-right:var(--van-field-label-margin-right);color:var(--van-field-label-color);text-align:left;word-wrap:break-word}.van-field__label--center{text-align:center}.van-field__label--right{text-align:right}.van-field__label--top{display:flex;width:100%;text-align:left;margin-bottom:var(--van-padding-base);overflow-wrap:break-word}.van-field__label--required:before{margin-right:2px;color:var(--van-field-required-mark-color);content:"*"}.van-field--disabled .van-field__label{color:var(--van-field-disabled-text-color)}.van-field__value{overflow:visible}.van-field__body{display:flex;align-items:center}.van-field__control{display:block;box-sizing:border-box;width:100%;min-width:0;margin:0;padding:0;color:var(--van-field-input-text-color);line-height:inherit;text-align:left;background-color:transparent;border:0;resize:none;-webkit-user-select:auto;user-select:auto}.van-field__control::-webkit-input-placeholder{color:var(--van-field-placeholder-text-color)}.van-field__control::placeholder{color:var(--van-field-placeholder-text-color)}.van-field__control:read-only{cursor:default}.van-field__control:disabled{color:var(--van-field-input-disabled-text-color);cursor:not-allowed;opacity:1;-webkit-text-fill-color:var(--van-field-input-disabled-text-color)}.van-field__control--center{justify-content:center;text-align:center}.van-field__control--right{justify-content:flex-end;text-align:right}.van-field__control--custom{display:flex;align-items:center;min-height:var(--van-cell-line-height)}.van-field__control--error::-webkit-input-placeholder{color:var(--van-field-input-error-text-color);-webkit-text-fill-color:currentColor}.van-field__control--error,.van-field__control--error::placeholder{color:var(--van-field-input-error-text-color);-webkit-text-fill-color:currentColor}.van-field__control--min-height{min-height:var(--van-field-text-area-min-height)}.van-field__control[type=date],.van-field__control[type=time],.van-field__control[type=datetime-local]{min-height:var(--van-cell-line-height)}.van-field__control[type=search]{-webkit-appearance:none}.van-field__clear,.van-field__icon,.van-field__button,.van-field__right-icon{flex-shrink:0}.van-field__clear,.van-field__right-icon{margin-right:calc(var(--van-padding-xs) * -1);padding:0 var(--van-padding-xs);line-height:inherit}.van-field__clear{color:var(--van-field-clear-icon-color);font-size:var(--van-field-clear-icon-size);cursor:pointer}.van-field__left-icon .van-icon,.van-field__right-icon .van-icon{display:block;font-size:var(--van-field-icon-size);line-height:inherit}.van-field__left-icon{margin-right:var(--van-padding-base)}.van-field__right-icon{color:var(--van-field-right-icon-color)}.van-field__button{padding-left:var(--van-padding-xs)}.van-field__error-message{color:var(--van-field-error-message-color);font-size:var(--van-field-error-message-font-size);text-align:left}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right}.van-field__word-limit{margin-top:var(--van-padding-base);color:var(--van-field-word-limit-color);font-size:var(--van-field-word-limit-font-size);line-height:var(--van-field-word-limit-line-height);text-align:right}

238
node_modules/vant/lib/field/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,238 @@
import { FieldProps } from './Field';
export declare const Field: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
tag: {
type: import("vue").PropType<keyof HTMLElementTagNameMap>;
default: keyof HTMLElementTagNameMap;
};
icon: StringConstructor;
size: import("vue").PropType<import("..").CellSize>;
title: (NumberConstructor | StringConstructor)[];
value: (NumberConstructor | StringConstructor)[];
label: (NumberConstructor | StringConstructor)[];
center: BooleanConstructor;
isLink: BooleanConstructor;
border: {
type: BooleanConstructor;
default: true;
};
iconPrefix: StringConstructor;
valueClass: import("vue").PropType<unknown>;
labelClass: import("vue").PropType<unknown>;
titleClass: import("vue").PropType<unknown>;
titleStyle: import("vue").PropType<string | import("vue").CSSProperties>;
arrowDirection: import("vue").PropType<import("..").CellArrowDirection>;
required: {
type: import("vue").PropType<boolean | "auto">;
default: null;
};
clickable: {
type: import("vue").PropType<boolean | null>;
default: null;
};
} & {
id: StringConstructor;
name: StringConstructor;
leftIcon: StringConstructor;
rightIcon: StringConstructor;
autofocus: BooleanConstructor;
clearable: BooleanConstructor;
maxlength: (NumberConstructor | StringConstructor)[];
max: NumberConstructor;
min: NumberConstructor;
formatter: import("vue").PropType<(value: string) => string>;
clearIcon: {
type: import("vue").PropType<string>;
default: string;
};
modelValue: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
inputAlign: import("vue").PropType<import("./types").FieldTextAlign>;
placeholder: StringConstructor;
autocomplete: StringConstructor;
autocapitalize: StringConstructor;
autocorrect: StringConstructor;
errorMessage: StringConstructor;
enterkeyhint: StringConstructor;
clearTrigger: {
type: import("vue").PropType<import("./types").FieldClearTrigger>;
default: import("./types").FieldClearTrigger;
};
formatTrigger: {
type: import("vue").PropType<import("./types").FieldFormatTrigger>;
default: import("./types").FieldFormatTrigger;
};
spellcheck: {
type: BooleanConstructor;
default: null;
};
error: {
type: BooleanConstructor;
default: null;
};
disabled: {
type: BooleanConstructor;
default: null;
};
readonly: {
type: BooleanConstructor;
default: null;
};
inputmode: import("vue").PropType<import("vue").HTMLAttributes["inputmode"]>;
} & {
rows: (NumberConstructor | StringConstructor)[];
type: {
type: import("vue").PropType<import("./types").FieldType>;
default: import("./types").FieldType;
};
rules: import("vue").PropType<import("./types").FieldRule[]>;
autosize: import("vue").PropType<boolean | import("./types").FieldAutosizeConfig>;
labelWidth: (NumberConstructor | StringConstructor)[];
labelClass: import("vue").PropType<unknown>;
labelAlign: import("vue").PropType<import("./types").FieldTextAlign>;
showWordLimit: BooleanConstructor;
errorMessageAlign: import("vue").PropType<import("./types").FieldTextAlign>;
colon: {
type: BooleanConstructor;
default: null;
};
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("clear" | "focus" | "blur" | "keypress" | "clickInput" | "endValidate" | "startValidate" | "clickLeftIcon" | "clickRightIcon" | "update:modelValue")[], "clear" | "focus" | "blur" | "keypress" | "clickInput" | "endValidate" | "startValidate" | "clickLeftIcon" | "clickRightIcon" | "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
tag: {
type: import("vue").PropType<keyof HTMLElementTagNameMap>;
default: keyof HTMLElementTagNameMap;
};
icon: StringConstructor;
size: import("vue").PropType<import("..").CellSize>;
title: (NumberConstructor | StringConstructor)[];
value: (NumberConstructor | StringConstructor)[];
label: (NumberConstructor | StringConstructor)[];
center: BooleanConstructor;
isLink: BooleanConstructor;
border: {
type: BooleanConstructor;
default: true;
};
iconPrefix: StringConstructor;
valueClass: import("vue").PropType<unknown>;
labelClass: import("vue").PropType<unknown>;
titleClass: import("vue").PropType<unknown>;
titleStyle: import("vue").PropType<string | import("vue").CSSProperties>;
arrowDirection: import("vue").PropType<import("..").CellArrowDirection>;
required: {
type: import("vue").PropType<boolean | "auto">;
default: null;
};
clickable: {
type: import("vue").PropType<boolean | null>;
default: null;
};
} & {
id: StringConstructor;
name: StringConstructor;
leftIcon: StringConstructor;
rightIcon: StringConstructor;
autofocus: BooleanConstructor;
clearable: BooleanConstructor;
maxlength: (NumberConstructor | StringConstructor)[];
max: NumberConstructor;
min: NumberConstructor;
formatter: import("vue").PropType<(value: string) => string>;
clearIcon: {
type: import("vue").PropType<string>;
default: string;
};
modelValue: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
inputAlign: import("vue").PropType<import("./types").FieldTextAlign>;
placeholder: StringConstructor;
autocomplete: StringConstructor;
autocapitalize: StringConstructor;
autocorrect: StringConstructor;
errorMessage: StringConstructor;
enterkeyhint: StringConstructor;
clearTrigger: {
type: import("vue").PropType<import("./types").FieldClearTrigger>;
default: import("./types").FieldClearTrigger;
};
formatTrigger: {
type: import("vue").PropType<import("./types").FieldFormatTrigger>;
default: import("./types").FieldFormatTrigger;
};
spellcheck: {
type: BooleanConstructor;
default: null;
};
error: {
type: BooleanConstructor;
default: null;
};
disabled: {
type: BooleanConstructor;
default: null;
};
readonly: {
type: BooleanConstructor;
default: null;
};
inputmode: import("vue").PropType<import("vue").HTMLAttributes["inputmode"]>;
} & {
rows: (NumberConstructor | StringConstructor)[];
type: {
type: import("vue").PropType<import("./types").FieldType>;
default: import("./types").FieldType;
};
rules: import("vue").PropType<import("./types").FieldRule[]>;
autosize: import("vue").PropType<boolean | import("./types").FieldAutosizeConfig>;
labelWidth: (NumberConstructor | StringConstructor)[];
labelClass: import("vue").PropType<unknown>;
labelAlign: import("vue").PropType<import("./types").FieldTextAlign>;
showWordLimit: BooleanConstructor;
errorMessageAlign: import("vue").PropType<import("./types").FieldTextAlign>;
colon: {
type: BooleanConstructor;
default: null;
};
}>> & Readonly<{
onFocus?: ((...args: any[]) => any) | undefined;
onBlur?: ((...args: any[]) => any) | undefined;
onKeypress?: ((...args: any[]) => any) | undefined;
onClear?: ((...args: any[]) => any) | undefined;
onClickInput?: ((...args: any[]) => any) | undefined;
onEndValidate?: ((...args: any[]) => any) | undefined;
onStartValidate?: ((...args: any[]) => any) | undefined;
onClickLeftIcon?: ((...args: any[]) => any) | undefined;
onClickRightIcon?: ((...args: any[]) => any) | undefined;
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
}>, {
type: import("./types").FieldType;
tag: keyof HTMLElementTagNameMap;
center: boolean;
autofocus: boolean;
disabled: boolean;
border: boolean;
isLink: boolean;
required: boolean | "auto";
clickable: boolean | null;
clearable: boolean;
clearIcon: string;
modelValue: string | number;
clearTrigger: import("./types").FieldClearTrigger;
formatTrigger: import("./types").FieldFormatTrigger;
spellcheck: boolean;
error: boolean;
readonly: boolean;
showWordLimit: boolean;
colon: boolean;
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
export default Field;
export { fieldProps } from './Field';
export type { FieldProps };
export type { FieldType, FieldRule, FieldInstance, FieldTextAlign, FieldThemeVars, FieldRuleMessage, FieldClearTrigger, FieldFormatTrigger, FieldRuleValidator, FieldRuleFormatter, FieldValidateError, FieldAutosizeConfig, FieldValidateTrigger, FieldValidationStatus, } from './types';
declare module 'vue' {
interface GlobalComponents {
VanField: typeof Field;
}
}

39
node_modules/vant/lib/field/index.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
Field: () => Field,
default: () => stdin_default,
fieldProps: () => import_Field2.fieldProps
});
module.exports = __toCommonJS(stdin_exports);
var import_utils = require("../utils");
var import_Field = __toESM(require("./Field"));
var import_Field2 = require("./Field");
const Field = (0, import_utils.withInstall)(import_Field.default);
var stdin_default = Field;

1
node_modules/vant/lib/field/style/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

5
node_modules/vant/lib/field/style/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
require("../../style/base.css");
require("../../badge/index.css");
require("../../icon/index.css");
require("../../cell/index.css");
require("../index.css");

65
node_modules/vant/lib/field/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,65 @@
import type { ComputedRef, ComponentPublicInstance } from 'vue';
import type { FieldProps } from './Field';
export type FieldType = 'tel' | 'url' | 'date' | 'file' | 'text' | 'time' | 'week' | 'color' | 'digit' | 'email' | 'image' | 'month' | 'radio' | 'range' | 'reset' | 'button' | 'hidden' | 'number' | 'search' | 'submit' | 'checkbox' | 'password' | 'textarea' | 'datetime-local';
export type FieldTextAlign = 'left' | 'center' | 'right' | 'top';
export type FieldClearTrigger = 'always' | 'focus';
export type FieldFormatTrigger = 'onBlur' | 'onChange';
export type FieldValidateTrigger = 'onBlur' | 'onChange' | 'onSubmit';
export type FieldAutosizeConfig = {
maxHeight?: number;
minHeight?: number;
};
export type FieldValidateError = {
name?: string;
message: string;
};
export type FieldRuleMessage = string | ((value: any, rule: FieldRule) => string);
export type FieldRuleValidator = (value: any, rule: FieldRule) => boolean | string | Promise<boolean | string>;
export type FieldRuleFormatter = (value: any, rule: FieldRule) => string;
export type FieldRule = {
pattern?: RegExp;
trigger?: FieldValidateTrigger | FieldValidateTrigger[];
message?: FieldRuleMessage;
required?: boolean;
validator?: FieldRuleValidator;
formatter?: FieldRuleFormatter;
validateEmpty?: boolean;
};
export type FieldValidationStatus = 'passed' | 'failed' | 'unvalidated';
export type FieldFormSharedProps = 'colon' | 'required' | 'disabled' | 'readonly' | 'labelWidth' | 'labelAlign' | 'inputAlign' | 'errorMessageAlign';
export type FieldExpose = {
blur: () => void | undefined;
focus: () => void | undefined;
validate: (rules?: FieldRule[] | undefined) => Promise<void | FieldValidateError>;
resetValidation: () => void;
getValidationStatus: () => FieldValidationStatus;
/** @private */
formValue: ComputedRef<unknown>;
};
export type FieldInstance = ComponentPublicInstance<FieldProps, FieldExpose>;
declare global {
interface EventTarget {
composing?: boolean;
}
}
export type FieldThemeVars = {
fieldLabelWidth?: string;
fieldLabelColor?: string;
fieldLabelMarginRight?: string;
fieldInputTextColor?: string;
fieldInputErrorTextColor?: string;
fieldInputDisabledTextColor?: string;
fieldPlaceholderTextColor?: string;
fieldIconSize?: string;
fieldClearIconSize?: string;
fieldClearIconColor?: string;
fieldRightIconColor?: string;
fieldErrorMessageColor?: string;
fieldErrorMessageFontSize?: string;
fieldTextAreaMinHeight?: string;
fieldWordLimitColor?: string;
fieldWordLimitFontSize?: string;
fieldWordLimitLineHeight?: number | string;
fieldDisabledTextColor?: string;
fieldRequiredMarkColor?: string;
};

15
node_modules/vant/lib/field/types.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
module.exports = __toCommonJS(stdin_exports);

15
node_modules/vant/lib/field/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { HTMLAttributes, InputHTMLAttributes } from 'vue';
import type { FieldRule, FieldType, FieldAutosizeConfig } from './types';
export declare function isEmptyValue(value: unknown): boolean;
export declare function runSyncRule(value: unknown, rule: FieldRule): boolean;
export declare function runRuleValidator(value: unknown, rule: FieldRule): Promise<unknown>;
export declare function getRuleMessage(value: unknown, rule: FieldRule): string;
export declare function startComposing({ target }: Event): void;
export declare function endComposing({ target }: Event): void;
export declare function resizeTextarea(input: HTMLInputElement, autosize: true | FieldAutosizeConfig): void;
export declare function mapInputType(type: FieldType, inputmode?: HTMLAttributes['inputmode']): {
type: InputHTMLAttributes['type'];
inputmode?: HTMLAttributes['inputmode'];
};
export declare function getStringLength(str: string): number;
export declare function cutString(str: string, maxlength: number): string;

116
node_modules/vant/lib/field/utils.js generated vendored Normal file
View File

@@ -0,0 +1,116 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
cutString: () => cutString,
endComposing: () => endComposing,
getRuleMessage: () => getRuleMessage,
getStringLength: () => getStringLength,
isEmptyValue: () => isEmptyValue,
mapInputType: () => mapInputType,
resizeTextarea: () => resizeTextarea,
runRuleValidator: () => runRuleValidator,
runSyncRule: () => runSyncRule,
startComposing: () => startComposing
});
module.exports = __toCommonJS(stdin_exports);
var import_utils = require("../utils");
function isEmptyValue(value) {
if (Array.isArray(value)) {
return !value.length;
}
if (value === 0) {
return false;
}
return !value;
}
function runSyncRule(value, rule) {
if (isEmptyValue(value)) {
if (rule.required) {
return false;
}
if (rule.validateEmpty === false) {
return true;
}
}
if (rule.pattern && !rule.pattern.test(String(value))) {
return false;
}
return true;
}
function runRuleValidator(value, rule) {
return new Promise((resolve) => {
const returnVal = rule.validator(value, rule);
if ((0, import_utils.isPromise)(returnVal)) {
returnVal.then(resolve);
return;
}
resolve(returnVal);
});
}
function getRuleMessage(value, rule) {
const { message } = rule;
if ((0, import_utils.isFunction)(message)) {
return message(value, rule);
}
return message || "";
}
function startComposing({ target }) {
target.composing = true;
}
function endComposing({ target }) {
if (target.composing) {
target.composing = false;
target.dispatchEvent(new Event("input"));
}
}
function resizeTextarea(input, autosize) {
const scrollTop = (0, import_utils.getRootScrollTop)();
input.style.height = "auto";
let height = input.scrollHeight;
if ((0, import_utils.isObject)(autosize)) {
const { maxHeight, minHeight } = autosize;
if (maxHeight !== void 0) {
height = Math.min(height, maxHeight);
}
if (minHeight !== void 0) {
height = Math.max(height, minHeight);
}
}
if (height) {
input.style.height = `${height}px`;
(0, import_utils.setRootScrollTop)(scrollTop);
}
}
function mapInputType(type, inputmode) {
if (type === "number") {
type = "text";
inputmode != null ? inputmode : inputmode = "decimal";
}
if (type === "digit") {
type = "tel";
inputmode != null ? inputmode : inputmode = "numeric";
}
return { type, inputmode };
}
function getStringLength(str) {
return [...str].length;
}
function cutString(str, maxlength) {
return [...str].slice(0, maxlength).join("");
}