iter: c02 textField/textarea 补 disabled 禁用态(布尔或信号绑定)

This commit is contained in:
HIsheR
2026-10-23 16:10:32 +08:00
parent 2a5892a88c
commit f9324ddc6a
11 changed files with 52 additions and 16 deletions
+2 -2
View File
@@ -1,9 +1,9 @@
import { effect, h } from '@ui-arch/frame';
import type { TextFieldProps } from './types.js';
/*** 文本输入:value 信号双向绑定,onInput 为输入回调 ***/
/*** 文本输入:value 信号双向绑定,disabled 支持布尔或信号禁用,onInput 为输入回调 ***/
export function textField(props: TextFieldProps): HTMLInputElement {
const el = h('input', { class: 'ua-input', placeholder: props.placeholder ?? '' }) as HTMLInputElement;
const el = h('input', { class: 'ua-input', placeholder: props.placeholder ?? '', disabled: props.disabled }) as HTMLInputElement; // false/undefined 移除属性,Signal 走响应式
if (props.value) {
const signal = props.value;
el.addEventListener('input', () => signal(el.value)); // 用户输入写回信号