示例工程 16-shadcn-ui-component-layer

16-shadcn-ui-component-layer/demo-03-select-toast/README.md

markdown · 0.7 KB

# demo-03-select-toast

两个小状态机:Select 通过 `items` 把值映射成标签;Toast 队列按 id 去重、
超过上限淘汰最旧的、关闭时按 id 删除。

## 运行

```bash
pnpm --filter @tutorial/16-shadcn-ui-component-layer-demo-03-select-toast start
```

## 验证

```bash
pnpm --filter @tutorial/16-shadcn-ui-component-layer-demo-03-select-toast smoke
# {"evt":"smoke","ok":true,"label":"Serif","ids":["b","c","d"]}
```

## 说明

- Select 的值是稳定的 id,标签只用于展示;换文案不改值。
- Toast 的 id 稳定,重复 add 是替换而不是新增。
- 上限 3 只是演示;真实应用按窗口/屏幕空间定。

## 已知限制

- 不涉及动画、aria-live 与多窗口归属。