iter(g03): 输入组件补 prefix/suffix 附加块

This commit is contained in:
HIsheR
2026-10-23 19:04:27 +08:00
parent d5ac26af31
commit bfa70132da
11 changed files with 170 additions and 29 deletions
+4 -3
View File
@@ -1,8 +1,9 @@
import { effect, h } from '@ui-arch/frame';
import { addonWrap } from './addons.js';
import type { TextareaProps } from './types.js';
/*** 多行输入:value 信号双向绑定,disabled 支持布尔或信号禁用,onInput 为输入回调 ***/
export function textarea(props: TextareaProps): HTMLTextAreaElement {
/*** 多行输入:value 信号双向绑定,disabled 支持布尔或信号禁用,onInput 为输入回调;prefix/suffix 包纵向附加组 ***/
export function textarea(props: TextareaProps): HTMLElement {
const el = h('textarea', { class: 'ua-textarea', rows: props.rows ?? 3, placeholder: props.placeholder ?? '', disabled: props.disabled }) as HTMLTextAreaElement; // false/undefined 移除属性,Signal 走响应式
if (props.value) {
const signal = props.value;
@@ -12,5 +13,5 @@ export function textarea(props: TextareaProps): HTMLTextAreaElement {
});
}
if (props.onInput) el.addEventListener('input', () => props.onInput!(el.value));
return el;
return addonWrap(el, props.prefix, props.suffix, true);
}