iter(g258): select 增加可访问名参数

This commit is contained in:
HIsheR
2026-10-26 22:21:04 +08:00
parent 9a1a6f9ed1
commit 3036f26505
6 changed files with 21 additions and 4 deletions
+1
View File
@@ -39,6 +39,7 @@ export function select(props: SelectProps): HTMLElement {
class: `ua-select-trigger${props.size && props.size !== 'md' ? ` is-${props.size}` : ''}`,
'aria-haspopup': 'listbox',
'aria-expanded': () => String(open()),
'aria-label': props.ariaLabel ?? null, // 无可见 label 时由调用方给名字,null 让 h() 不落属性
disabled: props.disabled, // 布尔或信号禁用,h() 直接透传(原生 button 拦截点击)
onClick: () => open(!open()),
},
+1
View File
@@ -20,6 +20,7 @@ export function tablePager(props: TablePagerProps): HTMLElement {
const sizeSelect = select({
size: 'sm',
options: list.map((n) => ({ value: String(n), label: `${n} 条/页` })),
ariaLabel: '每页条数', // 触发器只显示「5 条/页」这类量词,读屏需要主语
value: sizeSig,
disabled: () => props.loading(), // 加载中不改页大小:避免与在途结果竞争
onChange: (v) => props.onPageSize(Number(v)),
+1
View File
@@ -119,6 +119,7 @@ export interface SelectProps {
disabled?: boolean | Signal<boolean>; // 禁用态:布尔直接置位,传信号则动态同步
searchable?: boolean; // 弹层顶部带搜索框,按标签包含匹配过滤;缺省 false
clearable?: boolean; // 有值时触发器右缘出现清空按钮(删除 / Backspace 亦可清);缺省 false
ariaLabel?: string; // 触发器的可访问名:无可见 labelfor 关联时(如表格分页条的「每页条数」)用它给读屏一个名字
onChange?: (value: string) => void; // 变更回调
}