diff --git a/packages/opendesign/src/_components/in-textarea/InTextarea.vue b/packages/opendesign/src/_components/in-textarea/InTextarea.vue index 56f3403ae8bfe8269ee595559f87e83053a87166..cc629e75f47dc600cea7089a414d6465dd5fae22 100644 --- a/packages/opendesign/src/_components/in-textarea/InTextarea.vue +++ b/packages/opendesign/src/_components/in-textarea/InTextarea.vue @@ -4,7 +4,7 @@ import { inTextareaProps } from './types'; import { IconClose } from '../../_utils/icons'; import { useInput } from '../../_headless/use-input'; import { useI18n } from '../../locale'; -import { vScrollbar } from '../../scrollbar'; +import { vScrollbar, type BaseScrollerPropsT } from '../../scrollbar'; const props = defineProps(inTextareaProps); @@ -89,8 +89,8 @@ const mirrorValue = computed(() => { const scrollbarProps = computed(() => { if (props.scrollbar === true) { return { - showType: 'hover', - size: 'small', + showType: 'hover' as BaseScrollerPropsT['showType'], + size: 'small' as BaseScrollerPropsT['size'], }; } return props.scrollbar; diff --git a/packages/opendesign/src/_components/in-textarea/types.ts b/packages/opendesign/src/_components/in-textarea/types.ts index c8c439ca6ea7f86015b73b5d781760a9e2097406..69b5bd3e3fdebcd8234fc0ff7624d5b71099d0b2 100644 --- a/packages/opendesign/src/_components/in-textarea/types.ts +++ b/packages/opendesign/src/_components/in-textarea/types.ts @@ -6,121 +6,141 @@ export type TextareaResizeT = (typeof TextareaResizeTypes)[number]; export const inTextareaProps = { /** - * 下拉框的值 - * v-model + * @zh-CN 双向绑定值 + * @en-US Two-way binding value */ modelValue: { type: String, }, /** - * 下拉框的默认值 - * 非受控 + * @zh-CN 非受控默认值 + * @en-US Non-controlled default value */ defaultValue: { type: String, }, /** - * 提示文本 + * @zh-CN 提示文本 + * @en-US Prompt text */ placeholder: { type: String, }, /** - * 是否禁用 + * @zh-CN 是否禁用 + * @en-US Whether to disable */ disabled: { type: Boolean, }, /** - * 是否只读 + * @zh-CN 是否只读 + * @en-US Whether to read-only */ readonly: { type: Boolean, }, /** - * 是否可以清除 + * @zh-CN 是否可以清除 + * @en-US Whether to clear */ clearable: { type: Boolean, }, /** - * 对值格式化,控制显示格式 + * @zh-CN 格式化函数,控制显示格式 + * @en-US Format function, control display format */ format: { type: Function as PropType<(value: string) => string>, }, /** - * 判断值的有效性 + * @zh-CN 校验函数 + * @en-US Validation function */ validate: { type: Function as PropType<(value: string) => boolean>, }, /** - * 输入为无效值时,在blur + * @zh-CN 输入非法值时的回调 + * @en-US Callback when input value is invalid */ valueOnInvalidChange: { type: Function as PropType<(inputValue: string, lastValidInputValue: string) => string>, }, /** - * 显示的行数 + * @zh-CN 同 textarea 的 rows 属性 + * @en-US The rows attribute of textarea */ rows: { type: Number, default: undefined, }, /** - * 显示的列数 + * @zh-CN 同 textarea 的 cols 属性 + * @en-US The cols attribute of textarea */ cols: { type: Number, default: undefined, }, /** - * 是否支持调整尺寸 ResizeT + * @zh-CN 是否支持调整尺寸 + * @en-US Whether to support resizing + * @default 'vertical' */ resize: { type: String as PropType, default: 'vertical', }, /** - * 最小字符长度 + * @zh-CN 字符最小长度 + * @en-US Minimum length of characters */ minLength: { type: Number, }, /** - * 最大字符长度 + * @zh-CN 字符最大长度 + * @en-US Maximum length of characters */ maxLength: { type: Number, }, /** - * 获取长度方法 + * @zh-CN 获取长度方法 + * @en-US The method of getting length */ getLength: { type: Function as PropType<(val: string) => number>, }, /** - * 超过最大字符长度时是否允许输入 + * @zh-CN 超过最大字符长度时是否允许输入 + * @en-US Whether to allow input when exceeding the maximum character length + * @default true */ inputOnOutlimit: { type: Boolean, default: true, }, /** - * 根据内容自动计算高度 + * @zh-CN 根据内容自动计算高度 + * @en-US Whether to automatically calculate height based on content */ autoSize: { type: Boolean, }, /** - * textarea id, 用于label关联 + * @zh-CN id, 用于关联label + * @en-US id, for associating label */ textareaId: { type: String, }, /** - * 使用内置scrollbar,支持传递scrollbar配置项 + * @zh-CN scrollbar配置 + * @en-US scrollbar configuration + * @default true */ scrollbar: { type: [Boolean, Object] as PropType>, diff --git a/packages/opendesign/src/_headless/use-input.ts b/packages/opendesign/src/_headless/use-input.ts index b122e9ca9687c85b7a51c31b0c7842e7b8a84b8f..5c62559875b37c2d09d6ec624af4f5e1b328c606 100644 --- a/packages/opendesign/src/_headless/use-input.ts +++ b/packages/opendesign/src/_headless/use-input.ts @@ -98,7 +98,7 @@ export function useInput(options: InputOptionT) { return r; }; - const inputEl = ref(); + const inputEl = ref(); // 正在输入中文,处理输入过程中触发input事件 const composition = useComposition({ el: inputEl }); diff --git a/packages/opendesign/src/textarea/OTextarea.vue b/packages/opendesign/src/textarea/OTextarea.vue index ce7b7db8a43da60368d93a8e5b9dfe950c75eb6e..08df185d0f917e85be2daee5bc5744d1e6046409 100644 --- a/packages/opendesign/src/textarea/OTextarea.vue +++ b/packages/opendesign/src/textarea/OTextarea.vue @@ -79,10 +79,14 @@ onMounted(() => { }); defineExpose({ + /** expose: Focus method */ focus: () => inTextareaRef.value?.focus(), + /** expose: Blur method */ blur: () => inTextareaRef.value?.blur(), + /** expose: Clear method */ clear: () => inTextareaRef.value?.clear(), - inputEl: () => inTextareaRef.value?.inputEl, + /** expose: Textarea element */ + inputEl: () => inTextareaRef.value?.inputEl as HTMLTextAreaElement | undefined, });