This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
import Input from './src/input.vue';
import type { SFCWithInstall } from 'element-plus/es/utils';
export declare const ElInput: SFCWithInstall<typeof Input>;
export default ElInput;
export * from './src/input';
export type { InputInstance } from './src/instance';

View File

@@ -0,0 +1,15 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var input$1 = require('./src/input2.js');
var input = require('./src/input.js');
var install = require('../../utils/vue/install.js');
const ElInput = install.withInstall(input$1["default"]);
exports.inputEmits = input.inputEmits;
exports.inputProps = input.inputProps;
exports.ElInput = ElInput;
exports["default"] = ElInput;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../../packages/components/input/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport Input from './src/input.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElInput: SFCWithInstall<typeof Input> = withInstall(Input)\nexport default ElInput\n\nexport * from './src/input'\nexport type { InputInstance } from './src/instance'\n"],"names":["withInstall","Input"],"mappings":";;;;;;;;AAEY,MAAC,OAAO,GAAGA,mBAAW,CAACC,kBAAK;;;;;;;"}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,122 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var iconsVue = require('@element-plus/icons-vue');
var index = require('../../../hooks/use-size/index.js');
var icon = require('../../../utils/vue/icon.js');
var typescript = require('../../../utils/typescript.js');
var index$1 = require('../../../hooks/use-aria/index.js');
var event = require('../../../constants/event.js');
var runtime = require('../../../utils/vue/props/runtime.js');
var shared = require('@vue/shared');
const inputProps = runtime.buildProps({
id: {
type: String,
default: void 0
},
size: index.useSizeProp,
disabled: Boolean,
modelValue: {
type: runtime.definePropType([
String,
Number,
Object
]),
default: ""
},
maxlength: {
type: [String, Number]
},
minlength: {
type: [String, Number]
},
type: {
type: String,
default: "text"
},
resize: {
type: String,
values: ["none", "both", "horizontal", "vertical"]
},
autosize: {
type: runtime.definePropType([Boolean, Object]),
default: false
},
autocomplete: {
type: runtime.definePropType(String),
default: "off"
},
formatter: {
type: Function
},
parser: {
type: Function
},
placeholder: {
type: String
},
form: {
type: String
},
readonly: Boolean,
clearable: Boolean,
clearIcon: {
type: icon.iconPropType,
default: iconsVue.CircleClose
},
showPassword: Boolean,
showWordLimit: Boolean,
suffixIcon: {
type: icon.iconPropType
},
prefixIcon: {
type: icon.iconPropType
},
containerRole: {
type: String,
default: void 0
},
tabindex: {
type: [String, Number],
default: 0
},
validateEvent: {
type: Boolean,
default: true
},
inputStyle: {
type: runtime.definePropType([Object, Array, String]),
default: () => typescript.mutable({})
},
autofocus: Boolean,
rows: {
type: Number,
default: 2
},
...index$1.useAriaProps(["ariaLabel"]),
inputmode: {
type: runtime.definePropType(String),
default: void 0
},
name: String
});
const inputEmits = {
[event.UPDATE_MODEL_EVENT]: (value) => shared.isString(value),
input: (value) => shared.isString(value),
change: (value) => shared.isString(value),
focus: (evt) => evt instanceof FocusEvent,
blur: (evt) => evt instanceof FocusEvent,
clear: () => true,
mouseleave: (evt) => evt instanceof MouseEvent,
mouseenter: (evt) => evt instanceof MouseEvent,
keydown: (evt) => evt instanceof Event,
compositionstart: (evt) => evt instanceof CompositionEvent,
compositionupdate: (evt) => evt instanceof CompositionEvent,
compositionend: (evt) => evt instanceof CompositionEvent
};
exports.inputEmits = inputEmits;
exports.inputProps = inputProps;
//# sourceMappingURL=input.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,443 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var core = require('@vueuse/core');
var lodashUnified = require('lodash-unified');
var index$4 = require('../../icon/index.js');
var iconsVue = require('@element-plus/icons-vue');
var utils = require('./utils.js');
var input = require('./input.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-attrs/index.js');
var useFormItem = require('../../form/src/hooks/use-form-item.js');
var useFormCommonProps = require('../../form/src/hooks/use-form-common-props.js');
var index$2 = require('../../../hooks/use-focus-controller/index.js');
var icon = require('../../../utils/vue/icon.js');
var index$3 = require('../../../hooks/use-composition/index.js');
var event = require('../../../constants/event.js');
var index$5 = require('../../../hooks/use-cursor/index.js');
var index$1 = require('../../../hooks/use-namespace/index.js');
var error = require('../../../utils/error.js');
var shared = require('@vue/shared');
const COMPONENT_NAME = "ElInput";
const __default__ = vue.defineComponent({
name: COMPONENT_NAME,
inheritAttrs: false
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: input.inputProps,
emits: input.inputEmits,
setup(__props, { expose, emit }) {
const props = __props;
const rawAttrs = vue.useAttrs();
const attrs = index.useAttrs();
const slots = vue.useSlots();
const containerKls = vue.computed(() => [
props.type === "textarea" ? nsTextarea.b() : nsInput.b(),
nsInput.m(inputSize.value),
nsInput.is("disabled", inputDisabled.value),
nsInput.is("exceed", inputExceed.value),
{
[nsInput.b("group")]: slots.prepend || slots.append,
[nsInput.m("prefix")]: slots.prefix || props.prefixIcon,
[nsInput.m("suffix")]: slots.suffix || props.suffixIcon || props.clearable || props.showPassword,
[nsInput.bm("suffix", "password-clear")]: showClear.value && showPwdVisible.value,
[nsInput.b("hidden")]: props.type === "hidden"
},
rawAttrs.class
]);
const wrapperKls = vue.computed(() => [
nsInput.e("wrapper"),
nsInput.is("focus", isFocused.value)
]);
const { form: elForm, formItem: elFormItem } = useFormItem.useFormItem();
const { inputId } = useFormItem.useFormItemInputId(props, {
formItemContext: elFormItem
});
const inputSize = useFormCommonProps.useFormSize();
const inputDisabled = useFormCommonProps.useFormDisabled();
const nsInput = index$1.useNamespace("input");
const nsTextarea = index$1.useNamespace("textarea");
const input = vue.shallowRef();
const textarea = vue.shallowRef();
const hovering = vue.ref(false);
const passwordVisible = vue.ref(false);
const countStyle = vue.ref();
const textareaCalcStyle = vue.shallowRef(props.inputStyle);
const _ref = vue.computed(() => input.value || textarea.value);
const { wrapperRef, isFocused, handleFocus, handleBlur } = index$2.useFocusController(_ref, {
disabled: inputDisabled,
afterBlur() {
var _a;
if (props.validateEvent) {
(_a = elFormItem == null ? void 0 : elFormItem.validate) == null ? void 0 : _a.call(elFormItem, "blur").catch((err) => error.debugWarn());
}
}
});
const needStatusIcon = vue.computed(() => {
var _a;
return (_a = elForm == null ? void 0 : elForm.statusIcon) != null ? _a : false;
});
const validateState = vue.computed(() => (elFormItem == null ? void 0 : elFormItem.validateState) || "");
const validateIcon = vue.computed(() => validateState.value && icon.ValidateComponentsMap[validateState.value]);
const passwordIcon = vue.computed(() => passwordVisible.value ? iconsVue.View : iconsVue.Hide);
const containerStyle = vue.computed(() => [
rawAttrs.style
]);
const textareaStyle = vue.computed(() => [
props.inputStyle,
textareaCalcStyle.value,
{ resize: props.resize }
]);
const nativeInputValue = vue.computed(() => lodashUnified.isNil(props.modelValue) ? "" : String(props.modelValue));
const showClear = vue.computed(() => props.clearable && !inputDisabled.value && !props.readonly && !!nativeInputValue.value && (isFocused.value || hovering.value));
const showPwdVisible = vue.computed(() => props.showPassword && !inputDisabled.value && !!nativeInputValue.value);
const isWordLimitVisible = vue.computed(() => props.showWordLimit && !!props.maxlength && (props.type === "text" || props.type === "textarea") && !inputDisabled.value && !props.readonly && !props.showPassword);
const textLength = vue.computed(() => nativeInputValue.value.length);
const inputExceed = vue.computed(() => !!isWordLimitVisible.value && textLength.value > Number(props.maxlength));
const suffixVisible = vue.computed(() => !!slots.suffix || !!props.suffixIcon || showClear.value || props.showPassword || isWordLimitVisible.value || !!validateState.value && needStatusIcon.value);
const [recordCursor, setCursor] = index$5.useCursor(input);
core.useResizeObserver(textarea, (entries) => {
onceInitSizeTextarea();
if (!isWordLimitVisible.value || props.resize !== "both")
return;
const entry = entries[0];
const { width } = entry.contentRect;
countStyle.value = {
right: `calc(100% - ${width + 15 + 6}px)`
};
});
const resizeTextarea = () => {
const { type, autosize } = props;
if (!core.isClient || type !== "textarea" || !textarea.value)
return;
if (autosize) {
const minRows = shared.isObject(autosize) ? autosize.minRows : void 0;
const maxRows = shared.isObject(autosize) ? autosize.maxRows : void 0;
const textareaStyle2 = utils.calcTextareaHeight(textarea.value, minRows, maxRows);
textareaCalcStyle.value = {
overflowY: "hidden",
...textareaStyle2
};
vue.nextTick(() => {
textarea.value.offsetHeight;
textareaCalcStyle.value = textareaStyle2;
});
} else {
textareaCalcStyle.value = {
minHeight: utils.calcTextareaHeight(textarea.value).minHeight
};
}
};
const createOnceInitResize = (resizeTextarea2) => {
let isInit = false;
return () => {
var _a;
if (isInit || !props.autosize)
return;
const isElHidden = ((_a = textarea.value) == null ? void 0 : _a.offsetParent) === null;
if (!isElHidden) {
setTimeout(resizeTextarea2);
isInit = true;
}
};
};
const onceInitSizeTextarea = createOnceInitResize(resizeTextarea);
const setNativeInputValue = () => {
const input2 = _ref.value;
const formatterValue = props.formatter ? props.formatter(nativeInputValue.value) : nativeInputValue.value;
if (!input2 || input2.value === formatterValue)
return;
input2.value = formatterValue;
};
const handleInput = async (event$1) => {
recordCursor();
let { value } = event$1.target;
if (props.formatter && props.parser) {
value = props.parser(value);
}
if (isComposing.value)
return;
if (value === nativeInputValue.value) {
setNativeInputValue();
return;
}
emit(event.UPDATE_MODEL_EVENT, value);
emit(event.INPUT_EVENT, value);
await vue.nextTick();
setNativeInputValue();
setCursor();
};
const handleChange = (event$1) => {
let { value } = event$1.target;
if (props.formatter && props.parser) {
value = props.parser(value);
}
emit(event.CHANGE_EVENT, value);
};
const {
isComposing,
handleCompositionStart,
handleCompositionUpdate,
handleCompositionEnd
} = index$3.useComposition({ emit, afterComposition: handleInput });
const handlePasswordVisible = () => {
recordCursor();
passwordVisible.value = !passwordVisible.value;
setTimeout(setCursor);
};
const focus = () => {
var _a;
return (_a = _ref.value) == null ? void 0 : _a.focus();
};
const blur = () => {
var _a;
return (_a = _ref.value) == null ? void 0 : _a.blur();
};
const handleMouseLeave = (evt) => {
hovering.value = false;
emit("mouseleave", evt);
};
const handleMouseEnter = (evt) => {
hovering.value = true;
emit("mouseenter", evt);
};
const handleKeydown = (evt) => {
emit("keydown", evt);
};
const select = () => {
var _a;
(_a = _ref.value) == null ? void 0 : _a.select();
};
const clear = () => {
emit(event.UPDATE_MODEL_EVENT, "");
emit(event.CHANGE_EVENT, "");
emit("clear");
emit(event.INPUT_EVENT, "");
};
vue.watch(() => props.modelValue, () => {
var _a;
vue.nextTick(() => resizeTextarea());
if (props.validateEvent) {
(_a = elFormItem == null ? void 0 : elFormItem.validate) == null ? void 0 : _a.call(elFormItem, "change").catch((err) => error.debugWarn());
}
});
vue.watch(nativeInputValue, () => setNativeInputValue());
vue.watch(() => props.type, async () => {
await vue.nextTick();
setNativeInputValue();
resizeTextarea();
});
vue.onMounted(() => {
if (!props.formatter && props.parser) ;
setNativeInputValue();
vue.nextTick(resizeTextarea);
});
expose({
input,
textarea,
ref: _ref,
textareaStyle,
autosize: vue.toRef(props, "autosize"),
isComposing,
focus,
blur,
select,
clear,
resizeTextarea
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass([
vue.unref(containerKls),
{
[vue.unref(nsInput).bm("group", "append")]: _ctx.$slots.append,
[vue.unref(nsInput).bm("group", "prepend")]: _ctx.$slots.prepend
}
]),
style: vue.normalizeStyle(vue.unref(containerStyle)),
onMouseenter: handleMouseEnter,
onMouseleave: handleMouseLeave
}, [
vue.createCommentVNode(" input "),
_ctx.type !== "textarea" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
vue.createCommentVNode(" prepend slot "),
_ctx.$slots.prepend ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: vue.normalizeClass(vue.unref(nsInput).be("group", "prepend"))
}, [
vue.renderSlot(_ctx.$slots, "prepend")
], 2)) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("div", {
ref_key: "wrapperRef",
ref: wrapperRef,
class: vue.normalizeClass(vue.unref(wrapperKls))
}, [
vue.createCommentVNode(" prefix slot "),
_ctx.$slots.prefix || _ctx.prefixIcon ? (vue.openBlock(), vue.createElementBlock("span", {
key: 0,
class: vue.normalizeClass(vue.unref(nsInput).e("prefix"))
}, [
vue.createElementVNode("span", {
class: vue.normalizeClass(vue.unref(nsInput).e("prefix-inner"))
}, [
vue.renderSlot(_ctx.$slots, "prefix"),
_ctx.prefixIcon ? (vue.openBlock(), vue.createBlock(vue.unref(index$4.ElIcon), {
key: 0,
class: vue.normalizeClass(vue.unref(nsInput).e("icon"))
}, {
default: vue.withCtx(() => [
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.prefixIcon)))
]),
_: 1
}, 8, ["class"])) : vue.createCommentVNode("v-if", true)
], 2)
], 2)) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("input", vue.mergeProps({
id: vue.unref(inputId),
ref_key: "input",
ref: input,
class: vue.unref(nsInput).e("inner")
}, vue.unref(attrs), {
name: _ctx.name,
minlength: _ctx.minlength,
maxlength: _ctx.maxlength,
type: _ctx.showPassword ? passwordVisible.value ? "text" : "password" : _ctx.type,
disabled: vue.unref(inputDisabled),
readonly: _ctx.readonly,
autocomplete: _ctx.autocomplete,
tabindex: _ctx.tabindex,
"aria-label": _ctx.ariaLabel,
placeholder: _ctx.placeholder,
style: _ctx.inputStyle,
form: _ctx.form,
autofocus: _ctx.autofocus,
role: _ctx.containerRole,
inputmode: _ctx.inputmode,
onCompositionstart: vue.unref(handleCompositionStart),
onCompositionupdate: vue.unref(handleCompositionUpdate),
onCompositionend: vue.unref(handleCompositionEnd),
onInput: handleInput,
onChange: handleChange,
onKeydown: handleKeydown
}), null, 16, ["id", "name", "minlength", "maxlength", "type", "disabled", "readonly", "autocomplete", "tabindex", "aria-label", "placeholder", "form", "autofocus", "role", "inputmode", "onCompositionstart", "onCompositionupdate", "onCompositionend"]),
vue.createCommentVNode(" suffix slot "),
vue.unref(suffixVisible) ? (vue.openBlock(), vue.createElementBlock("span", {
key: 1,
class: vue.normalizeClass(vue.unref(nsInput).e("suffix"))
}, [
vue.createElementVNode("span", {
class: vue.normalizeClass(vue.unref(nsInput).e("suffix-inner"))
}, [
!vue.unref(showClear) || !vue.unref(showPwdVisible) || !vue.unref(isWordLimitVisible) ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
vue.renderSlot(_ctx.$slots, "suffix"),
_ctx.suffixIcon ? (vue.openBlock(), vue.createBlock(vue.unref(index$4.ElIcon), {
key: 0,
class: vue.normalizeClass(vue.unref(nsInput).e("icon"))
}, {
default: vue.withCtx(() => [
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.suffixIcon)))
]),
_: 1
}, 8, ["class"])) : vue.createCommentVNode("v-if", true)
], 64)) : vue.createCommentVNode("v-if", true),
vue.unref(showClear) ? (vue.openBlock(), vue.createBlock(vue.unref(index$4.ElIcon), {
key: 1,
class: vue.normalizeClass([vue.unref(nsInput).e("icon"), vue.unref(nsInput).e("clear")]),
onMousedown: vue.withModifiers(vue.unref(shared.NOOP), ["prevent"]),
onClick: clear
}, {
default: vue.withCtx(() => [
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.clearIcon)))
]),
_: 1
}, 8, ["class", "onMousedown"])) : vue.createCommentVNode("v-if", true),
vue.unref(showPwdVisible) ? (vue.openBlock(), vue.createBlock(vue.unref(index$4.ElIcon), {
key: 2,
class: vue.normalizeClass([vue.unref(nsInput).e("icon"), vue.unref(nsInput).e("password")]),
onClick: handlePasswordVisible
}, {
default: vue.withCtx(() => [
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(passwordIcon))))
]),
_: 1
}, 8, ["class"])) : vue.createCommentVNode("v-if", true),
vue.unref(isWordLimitVisible) ? (vue.openBlock(), vue.createElementBlock("span", {
key: 3,
class: vue.normalizeClass(vue.unref(nsInput).e("count"))
}, [
vue.createElementVNode("span", {
class: vue.normalizeClass(vue.unref(nsInput).e("count-inner"))
}, vue.toDisplayString(vue.unref(textLength)) + " / " + vue.toDisplayString(_ctx.maxlength), 3)
], 2)) : vue.createCommentVNode("v-if", true),
vue.unref(validateState) && vue.unref(validateIcon) && vue.unref(needStatusIcon) ? (vue.openBlock(), vue.createBlock(vue.unref(index$4.ElIcon), {
key: 4,
class: vue.normalizeClass([
vue.unref(nsInput).e("icon"),
vue.unref(nsInput).e("validateIcon"),
vue.unref(nsInput).is("loading", vue.unref(validateState) === "validating")
])
}, {
default: vue.withCtx(() => [
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(validateIcon))))
]),
_: 1
}, 8, ["class"])) : vue.createCommentVNode("v-if", true)
], 2)
], 2)) : vue.createCommentVNode("v-if", true)
], 2),
vue.createCommentVNode(" append slot "),
_ctx.$slots.append ? (vue.openBlock(), vue.createElementBlock("div", {
key: 1,
class: vue.normalizeClass(vue.unref(nsInput).be("group", "append"))
}, [
vue.renderSlot(_ctx.$slots, "append")
], 2)) : vue.createCommentVNode("v-if", true)
], 64)) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
vue.createCommentVNode(" textarea "),
vue.createElementVNode("textarea", vue.mergeProps({
id: vue.unref(inputId),
ref_key: "textarea",
ref: textarea,
class: [vue.unref(nsTextarea).e("inner"), vue.unref(nsInput).is("focus", vue.unref(isFocused))]
}, vue.unref(attrs), {
minlength: _ctx.minlength,
maxlength: _ctx.maxlength,
tabindex: _ctx.tabindex,
disabled: vue.unref(inputDisabled),
readonly: _ctx.readonly,
autocomplete: _ctx.autocomplete,
style: vue.unref(textareaStyle),
"aria-label": _ctx.ariaLabel,
placeholder: _ctx.placeholder,
form: _ctx.form,
autofocus: _ctx.autofocus,
rows: _ctx.rows,
role: _ctx.containerRole,
onCompositionstart: vue.unref(handleCompositionStart),
onCompositionupdate: vue.unref(handleCompositionUpdate),
onCompositionend: vue.unref(handleCompositionEnd),
onInput: handleInput,
onFocus: vue.unref(handleFocus),
onBlur: vue.unref(handleBlur),
onChange: handleChange,
onKeydown: handleKeydown
}), null, 16, ["id", "minlength", "maxlength", "tabindex", "disabled", "readonly", "autocomplete", "aria-label", "placeholder", "form", "autofocus", "rows", "role", "onCompositionstart", "onCompositionupdate", "onCompositionend", "onFocus", "onBlur"]),
vue.unref(isWordLimitVisible) ? (vue.openBlock(), vue.createElementBlock("span", {
key: 0,
style: vue.normalizeStyle(countStyle.value),
class: vue.normalizeClass(vue.unref(nsInput).e("count"))
}, vue.toDisplayString(vue.unref(textLength)) + " / " + vue.toDisplayString(_ctx.maxlength), 7)) : vue.createCommentVNode("v-if", true)
], 64))
], 38);
};
}
});
var Input = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "input.vue"]]);
exports["default"] = Input;
//# sourceMappingURL=input2.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import type Input from './input.vue';
export type InputInstance = InstanceType<typeof Input> & unknown;

View File

@@ -0,0 +1,3 @@
'use strict';
//# sourceMappingURL=instance.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"instance.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}

View File

@@ -0,0 +1,6 @@
type TextAreaHeight = {
height: string;
minHeight?: string;
};
export declare function calcTextareaHeight(targetElement: HTMLTextAreaElement, minRows?: number, maxRows?: number): TextAreaHeight;
export {};

View File

@@ -0,0 +1,88 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var browser = require('../../../utils/browser.js');
var types = require('../../../utils/types.js');
let hiddenTextarea = void 0;
const HIDDEN_STYLE = {
height: "0",
visibility: "hidden",
overflow: browser.isFirefox() ? "" : "hidden",
position: "absolute",
"z-index": "-1000",
top: "0",
right: "0"
};
const CONTEXT_STYLE = [
"letter-spacing",
"line-height",
"padding-top",
"padding-bottom",
"font-family",
"font-weight",
"font-size",
"text-rendering",
"text-transform",
"width",
"text-indent",
"padding-left",
"padding-right",
"border-width",
"box-sizing",
"word-break"
];
function calculateNodeStyling(targetElement) {
const style = window.getComputedStyle(targetElement);
const boxSizing = style.getPropertyValue("box-sizing");
const paddingSize = Number.parseFloat(style.getPropertyValue("padding-bottom")) + Number.parseFloat(style.getPropertyValue("padding-top"));
const borderSize = Number.parseFloat(style.getPropertyValue("border-bottom-width")) + Number.parseFloat(style.getPropertyValue("border-top-width"));
const contextStyle = CONTEXT_STYLE.map((name) => [
name,
style.getPropertyValue(name)
]);
return { contextStyle, paddingSize, borderSize, boxSizing };
}
function calcTextareaHeight(targetElement, minRows = 1, maxRows) {
var _a, _b;
if (!hiddenTextarea) {
hiddenTextarea = document.createElement("textarea");
((_a = targetElement.parentNode) != null ? _a : document.body).appendChild(hiddenTextarea);
}
const { paddingSize, borderSize, boxSizing, contextStyle } = calculateNodeStyling(targetElement);
contextStyle.forEach(([key, value]) => hiddenTextarea == null ? void 0 : hiddenTextarea.style.setProperty(key, value));
Object.entries(HIDDEN_STYLE).forEach(([key, value]) => hiddenTextarea == null ? void 0 : hiddenTextarea.style.setProperty(key, value, "important"));
hiddenTextarea.value = targetElement.value || targetElement.placeholder || "";
let height = hiddenTextarea.scrollHeight;
const result = {};
if (boxSizing === "border-box") {
height = height + borderSize;
} else if (boxSizing === "content-box") {
height = height - paddingSize;
}
hiddenTextarea.value = "";
const singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
if (types.isNumber(minRows)) {
let minHeight = singleRowHeight * minRows;
if (boxSizing === "border-box") {
minHeight = minHeight + paddingSize + borderSize;
}
height = Math.max(minHeight, height);
result.minHeight = `${minHeight}px`;
}
if (types.isNumber(maxRows)) {
let maxHeight = singleRowHeight * maxRows;
if (boxSizing === "border-box") {
maxHeight = maxHeight + paddingSize + borderSize;
}
height = Math.min(maxHeight, height);
}
result.height = `${height}px`;
(_b = hiddenTextarea.parentNode) == null ? void 0 : _b.removeChild(hiddenTextarea);
hiddenTextarea = void 0;
return result;
}
exports.calcTextareaHeight = calcTextareaHeight;
//# sourceMappingURL=utils.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style/css';
import 'element-plus/theme-chalk/el-input.css';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/css.js');
require('element-plus/theme-chalk/el-input.css');
//# sourceMappingURL=css.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style';
import 'element-plus/theme-chalk/src/input.scss';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/index.js');
require('element-plus/theme-chalk/src/input.scss');
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}