( label: string, defaultValue: number = 1, icon: MenuItemIcon | undefined, callback: (value: number) => void, styles: MenuStyles = MENU_STYLES )
| 343 | * 创建带有数字输入框的菜单项 |
| 344 | */ |
| 345 | export function createNumberInputItem( |
| 346 | label: string, |
| 347 | defaultValue: number = 1, |
| 348 | icon: MenuItemIcon | undefined, |
| 349 | callback: (value: number) => void, |
| 350 | styles: MenuStyles = MENU_STYLES |
| 351 | ): HTMLElement { |
| 352 | // 创建容器 |
| 353 | const container = createElement('div'); |
| 354 | applyStyles(container, styles.inputContainer); |
| 355 | |
| 356 | // 创建左侧图标容器 |
| 357 | |
| 358 | // 添加图标 |
| 359 | if (icon) { |
| 360 | const iconEl = createIcon(icon, undefined, styles.menuItemIcon); |
| 361 | container.appendChild(iconEl); |
| 362 | } |
| 363 | // 创建标签 |
| 364 | const labelElement = createElement('label'); |
| 365 | labelElement.textContent = label; |
| 366 | applyStyles(labelElement, styles.inputLabel); |
| 367 | container.appendChild(labelElement); |
| 368 | |
| 369 | // 创建输入框 |
| 370 | const input = createElement('input') as HTMLInputElement; |
| 371 | input.type = 'number'; |
| 372 | input.min = '1'; |
| 373 | input.value = defaultValue.toString(); |
| 374 | applyStyles(input, styles.inputField); |
| 375 | container.appendChild(input); |
| 376 | // 创建包装容器 |
| 377 | const wrapper = createElement('div'); |
| 378 | wrapper.appendChild(container); |
| 379 | |
| 380 | return wrapper; |
| 381 | } |
| 382 | |
| 383 | /** |
| 384 | * 格式化用户传入的类名配置 |
nothing calls this directly
no test coverage detected