fix: textarea
parent
82f28ce3d0
commit
6594fe3964
|
@ -3,6 +3,7 @@ import { computed, defineComponent, shallowRef, ref, watch } from 'vue';
|
||||||
import PropTypes from './vue-types';
|
import PropTypes from './vue-types';
|
||||||
import type { BaseInputInnerExpose } from './BaseInputInner';
|
import type { BaseInputInnerExpose } from './BaseInputInner';
|
||||||
import BaseInputInner from './BaseInputInner';
|
import BaseInputInner from './BaseInputInner';
|
||||||
|
import { styleObjectToString } from '../vc-util/Dom/css';
|
||||||
|
|
||||||
export interface BaseInputExpose {
|
export interface BaseInputExpose {
|
||||||
focus: () => void;
|
focus: () => void;
|
||||||
|
@ -32,7 +33,7 @@ const BaseInput = defineComponent({
|
||||||
default: 'input',
|
default: 'input',
|
||||||
},
|
},
|
||||||
size: PropTypes.string,
|
size: PropTypes.string,
|
||||||
style: PropTypes.style,
|
style: PropTypes.oneOfType([String, Object]),
|
||||||
class: PropTypes.string,
|
class: PropTypes.string,
|
||||||
},
|
},
|
||||||
emits: [
|
emits: [
|
||||||
|
@ -134,13 +135,18 @@ const BaseInput = defineComponent({
|
||||||
const handlePaste = (e: ClipboardEvent) => {
|
const handlePaste = (e: ClipboardEvent) => {
|
||||||
emit('paste', e);
|
emit('paste', e);
|
||||||
};
|
};
|
||||||
|
const styleString = computed(() => {
|
||||||
|
return props.style && typeof props.style !== 'string'
|
||||||
|
? styleObjectToString(props.style)
|
||||||
|
: props.style;
|
||||||
|
});
|
||||||
return () => {
|
return () => {
|
||||||
const { tag: Tag, style, ...restProps } = props;
|
const { style, lazy, ...restProps } = props;
|
||||||
return (
|
return (
|
||||||
<BaseInputInner
|
<BaseInputInner
|
||||||
{...restProps}
|
{...restProps}
|
||||||
{...attrs}
|
{...attrs}
|
||||||
style={JSON.stringify(style)}
|
style={styleString.value}
|
||||||
onInput={handleInput}
|
onInput={handleInput}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import type { CSSProperties, VNodeTypes } from 'vue';
|
import type { CSSProperties, VNodeTypes } from 'vue';
|
||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
|
import { styleToString } from '../vc-util/Dom/css';
|
||||||
|
|
||||||
interface MeasureResult {
|
interface MeasureResult {
|
||||||
finished: boolean;
|
finished: boolean;
|
||||||
|
@ -23,13 +24,6 @@ const wrapperStyle: CSSProperties = {
|
||||||
lineHeight: 'inherit',
|
lineHeight: 'inherit',
|
||||||
};
|
};
|
||||||
|
|
||||||
function styleToString(style: CSSStyleDeclaration) {
|
|
||||||
// There are some different behavior between Firefox & Chrome.
|
|
||||||
// We have to handle this ourself.
|
|
||||||
const styleNames = Array.prototype.slice.apply(style);
|
|
||||||
return styleNames.map(name => `${name}: ${style.getPropertyValue(name)};`).join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetDomStyles(target: HTMLElement, origin: HTMLElement) {
|
function resetDomStyles(target: HTMLElement, origin: HTMLElement) {
|
||||||
target.setAttribute('aria-hidden', 'true');
|
target.setAttribute('aria-hidden', 'true');
|
||||||
const originStyle = window.getComputedStyle(origin);
|
const originStyle = window.getComputedStyle(origin);
|
||||||
|
|
|
@ -112,3 +112,16 @@ export function getOffset(node: any) {
|
||||||
(docElem.clientTop || document.body.clientTop || 0),
|
(docElem.clientTop || document.body.clientTop || 0),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function styleToString(style: CSSStyleDeclaration) {
|
||||||
|
// There are some different behavior between Firefox & Chrome.
|
||||||
|
// We have to handle this ourself.
|
||||||
|
const styleNames = Array.prototype.slice.apply(style);
|
||||||
|
return styleNames.map(name => `${name}: ${style.getPropertyValue(name)};`).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function styleObjectToString(style: Record<string, string>) {
|
||||||
|
return Object.keys(style)
|
||||||
|
.map(name => `${name}: ${style[name]};`)
|
||||||
|
.join('');
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue