weifuwu 0.87.0 → 0.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -135
- package/dist/client/components/ActionSheet/ActionSheet.d.ts +1 -1
- package/dist/client/components/AiChat/AiChat.d.ts +3 -4
- package/dist/client/components/ChatInput/ChatInput.d.ts +5 -0
- package/dist/client/components/CitationCard/CitationCard.d.ts +1 -1
- package/dist/client/components/Command/Command.d.ts +1 -1
- package/dist/client/components/ContextMenu/ContextMenu.d.ts +1 -1
- package/dist/client/components/DatePicker/DatePicker.d.ts +1 -1
- package/dist/client/components/Dropdown/Dropdown.d.ts +1 -1
- package/dist/client/components/Editor/model/html.d.ts +10 -0
- package/dist/client/components/ImageCropper/ImageCropper.d.ts +6 -2
- package/dist/client/components/Menu/Menu.d.ts +1 -1
- package/dist/client/components/NavMenu/NavMenu.d.ts +1 -1
- package/dist/client/components/Popconfirm/Popconfirm.d.ts +1 -1
- package/dist/client/components/SlideCanvas/SlideCanvas.d.ts +1 -1
- package/dist/client/components/Tour/Tour.d.ts +1 -1
- package/dist/client/components/TreeSelect/TreeSelect.d.ts +1 -1
- package/dist/client/components/index.js +41 -41
- package/dist/client/components/style.css +298 -644
- package/dist/client/layout/weifuwu-layout.css +286 -640
- package/dist/client/vdom/browser/Browser.d.ts +2 -0
- package/dist/client/vdom/commands.d.ts +4 -1
- package/dist/client/vdom/context/UIContext.d.ts +8 -0
- package/dist/client/vdom/core/diff/attrs.d.ts +10 -2
- package/dist/client/vdom/core/field/attributes.d.ts +12 -0
- package/dist/client/vdom/core/field/events.d.ts +8 -0
- package/dist/client/vdom/core/field/input-sync.d.ts +14 -0
- package/dist/client/vdom/core/field/key.d.ts +3 -0
- package/dist/client/vdom/core/field/props.d.ts +13 -1
- package/dist/client/vdom/core/field/ref.d.ts +6 -0
- package/dist/client/vdom/core/field/style.d.ts +7 -1
- package/dist/client/vdom/core/node/component.d.ts +3 -4
- package/dist/client/vdom/core/node/native.d.ts +6 -1
- package/dist/client/vdom/core/patch/index.d.ts +24 -1
- package/dist/client/vdom/core/patch/processors.d.ts +8 -1
- package/dist/client/vdom/core/protocol.d.ts +45 -0
- package/dist/client/vdom/core/router.d.ts +7 -0
- package/dist/client/vdom/core/ssr/absorb.d.ts +31 -4
- package/dist/client/vdom/core/transform/index.d.ts +6 -6
- package/dist/client/vdom/core/v2/cycle.d.ts +54 -0
- package/dist/client/vdom/core/v2/diff.d.ts +80 -0
- package/dist/client/vdom/core/v2/integrate.d.ts +24 -0
- package/dist/client/vdom/core/v2/render.d.ts +28 -0
- package/dist/client/vdom/core/v2/schedule.d.ts +33 -0
- package/dist/client/vdom/core/v2/serve.d.ts +4 -0
- package/dist/client/vdom/core/v2/spy.d.ts +21 -0
- package/dist/client/vdom/core/v2/ssr.d.ts +14 -0
- package/dist/client/vdom/core/vnode.d.ts +9 -6
- package/dist/client/vdom/dev/error-counter.d.ts +27 -0
- package/dist/client/vdom/dev/render-health.d.ts +60 -0
- package/dist/client/vdom/hooks/chat.d.ts +32 -5
- package/dist/client/vdom/hooks/drag-media.d.ts +3 -1
- package/dist/client/vdom/hooks/env.d.ts +32 -0
- package/dist/client/vdom/hooks/popup-manager.d.ts +21 -0
- package/dist/client/vdom/hooks/popup.d.ts +4 -1
- package/dist/client/vdom/hooks/stable.d.ts +4 -0
- package/dist/client/vdom/hooks/use-observable.d.ts +13 -0
- package/dist/client/vdom/index.d.ts +14 -6
- package/dist/client/vdom/index.js +4 -7
- package/dist/client/vdom/jsx-runtime.js +1 -1
- package/dist/client/vdom/middlewares/api.d.ts +8 -0
- package/dist/client/vdom/middlewares/auth-i18n.d.ts +7 -0
- package/dist/client/vdom/middlewares/ws.d.ts +41 -1
- package/dist/client/vdom/observable/index.d.ts +13 -0
- package/dist/client/vdom/observable/observable.d.ts +26 -0
- package/dist/client/vdom/observable/operators.d.ts +76 -0
- package/dist/client/vdom/observable/sources.d.ts +54 -0
- package/dist/client/vdom/observable/types.d.ts +45 -0
- package/dist/client/vdom/store.d.ts +17 -2
- package/dist/client/vdom/testing.js +2 -2
- package/dist/server/ai/agent.d.ts +18 -0
- package/dist/server/ai/client.d.ts +14 -2
- package/dist/server/ai/contracts.d.ts +2 -2
- package/dist/server/ai/sse.d.ts +6 -0
- package/dist/server/core/collect.d.ts +31 -0
- package/dist/server/core/error-counter.d.ts +11 -0
- package/dist/server/core/hub.d.ts +2 -0
- package/dist/server/core/router.d.ts +12 -9
- package/dist/server/db/contracts.d.ts +24 -0
- package/dist/server/db/memory-redis.d.ts +3 -4
- package/dist/server/db/memory-sql.d.ts +20 -4
- package/dist/server/db/postgres-server.d.ts +2 -0
- package/dist/server/db/query.d.ts +21 -0
- package/dist/server/db/redis-server.d.ts +4 -2
- package/dist/server/db/sql-parser.d.ts +2 -1
- package/dist/server/email/index.d.ts +2 -0
- package/dist/server/index.d.ts +4 -1
- package/dist/server/index.js +3927 -1982
- package/dist/server/messager/index.d.ts +21 -2
- package/dist/server/middleware/compress.d.ts +25 -0
- package/dist/server/ui/index.d.ts +8 -1
- package/dist/server/user/index.d.ts +4 -0
- package/dist/shared/router/chain.d.ts +9 -0
- package/dist/shared/router/context.d.ts +35 -0
- package/dist/shared/router/ctx-fields.d.ts +20 -0
- package/dist/shared/router/pipeline.d.ts +70 -0
- package/dist/shared/router/trie.d.ts +11 -3
- package/dist/shared/router/types.d.ts +23 -0
- package/docs/style-guide.md +44 -41
- package/package.json +13 -10
- package/content/apps/admin.md +0 -55
- package/content/apps/agent-platform.md +0 -35
- package/content/apps/auth.md +0 -49
- package/content/apps/multi.md +0 -44
- package/content/apps/todo.md +0 -51
- package/content/backend/ai.md +0 -28
- package/content/backend/auth.md +0 -20
- package/content/backend/email.md +0 -23
- package/content/backend/graphql.md +0 -23
- package/content/backend/http.md +0 -23
- package/content/backend/limit.md +0 -23
- package/content/backend/middleware.md +0 -17
- package/content/backend/queue.md +0 -23
- package/content/backend/redis.md +0 -26
- package/content/backend/router.md +0 -23
- package/content/backend/schedule.md +0 -23
- package/content/backend/sql.md +0 -27
- package/content/backend/sse.md +0 -26
- package/content/backend/ws.md +0 -26
- package/content/capabilities/app-node.md +0 -21
- package/content/capabilities/data.md +0 -21
- package/content/capabilities/events.md +0 -21
- package/content/capabilities/hooks.md +0 -22
- package/content/capabilities/i18n.md +0 -21
- package/content/capabilities/popup.md +0 -21
- package/content/capabilities/render-only.md +0 -23
- package/content/capabilities/router.md +0 -22
- package/content/capabilities/self-id.md +0 -21
- package/content/capabilities/store.md +0 -21
- package/content/capabilities/theme.md +0 -21
- package/content/capabilities/two-phase.md +0 -21
- package/content/components/accordion.md +0 -50
- package/content/components/actionsheet.md +0 -46
- package/content/components/affix.md +0 -51
- package/content/components/aichat.md +0 -57
- package/content/components/alert.md +0 -52
- package/content/components/alertgroup.md +0 -45
- package/content/components/anchor.md +0 -52
- package/content/components/app.md +0 -37
- package/content/components/approvalcard.md +0 -56
- package/content/components/appshell.md +0 -50
- package/content/components/aspectratio.md +0 -47
- package/content/components/authpage.md +0 -61
- package/content/components/autocomplete-v2.md +0 -40
- package/content/components/autocomplete.md +0 -56
- package/content/components/avatar.md +0 -51
- package/content/components/avatargroup.md +0 -47
- package/content/components/backtop.md +0 -53
- package/content/components/badge.md +0 -55
- package/content/components/breadcrumb.md +0 -49
- package/content/components/button.md +0 -63
- package/content/components/calendar-v2.md +0 -40
- package/content/components/calendar.md +0 -50
- package/content/components/card.md +0 -58
- package/content/components/carousel.md +0 -52
- package/content/components/cascader-v2.md +0 -39
- package/content/components/cascader.md +0 -54
- package/content/components/chart.md +0 -53
- package/content/components/chatinput.md +0 -63
- package/content/components/checkbox.md +0 -51
- package/content/components/checkboxgroup.md +0 -52
- package/content/components/citationcard.md +0 -48
- package/content/components/codeblock.md +0 -48
- package/content/components/codeeditor.md +0 -47
- package/content/components/collapse.md +0 -49
- package/content/components/colorpicker.md +0 -50
- package/content/components/command.md +0 -50
- package/content/components/confirm.md +0 -57
- package/content/components/contextmenu.md +0 -48
- package/content/components/copybutton.md +0 -51
- package/content/components/datepicker.md +0 -52
- package/content/components/descriptions-v2.md +0 -39
- package/content/components/descriptions.md +0 -52
- package/content/components/diffview-v2.md +0 -39
- package/content/components/diffview.md +0 -50
- package/content/components/divider.md +0 -48
- package/content/components/drawer.md +0 -55
- package/content/components/dropdown.md +0 -53
- package/content/components/editor.md +0 -49
- package/content/components/emptystate.md +0 -51
- package/content/components/exportcsv.md +0 -38
- package/content/components/field.md +0 -54
- package/content/components/filepreview-office.md +0 -37
- package/content/components/filepreview.md +0 -49
- package/content/components/filetree.md +0 -56
- package/content/components/fileupload-v2.md +0 -39
- package/content/components/fileupload.md +0 -57
- package/content/components/floatbutton.md +0 -52
- package/content/components/form-v2.md +0 -41
- package/content/components/form.md +0 -60
- package/content/components/grid.md +0 -51
- package/content/components/highlight-v2.md +0 -39
- package/content/components/highlight.md +0 -46
- package/content/components/hovercard.md +0 -51
- package/content/components/icon.md +0 -50
- package/content/components/imagecropper.md +0 -45
- package/content/components/img.md +0 -56
- package/content/components/infinitescroll-v2.md +0 -40
- package/content/components/infinitescroll.md +0 -54
- package/content/components/input.md +0 -65
- package/content/components/inputnumber.md +0 -58
- package/content/components/inview.md +0 -56
- package/content/components/jsonschemaform.md +0 -53
- package/content/components/jsonviewer-v2.md +0 -39
- package/content/components/jsonviewer.md +0 -49
- package/content/components/kanban.md +0 -46
- package/content/components/label.md +0 -48
- package/content/components/layout.md +0 -54
- package/content/components/layoutcontent.md +0 -43
- package/content/components/layoutheader.md +0 -43
- package/content/components/layoutsider.md +0 -43
- package/content/components/link.md +0 -52
- package/content/components/list.md +0 -44
- package/content/components/loading.md +0 -45
- package/content/components/logviewer-v2.md +0 -39
- package/content/components/logviewer.md +0 -53
- package/content/components/markdown.md +0 -51
- package/content/components/markdowneditor.md +0 -47
- package/content/components/math.md +0 -42
- package/content/components/mentions-v2.md +0 -39
- package/content/components/mentions.md +0 -52
- package/content/components/menu.md +0 -56
- package/content/components/menubar.md +0 -44
- package/content/components/messagebubble.md +0 -50
- package/content/components/modal.md +0 -59
- package/content/components/navmenu.md +0 -47
- package/content/components/notification.md +0 -51
- package/content/components/pageheader.md +0 -53
- package/content/components/pagination.md +0 -49
- package/content/components/paragraph.md +0 -45
- package/content/components/passwordinput.md +0 -57
- package/content/components/pininput-v2.md +0 -39
- package/content/components/pininput.md +0 -50
- package/content/components/pipeline.md +0 -49
- package/content/components/popconfirm.md +0 -58
- package/content/components/popover.md +0 -61
- package/content/components/progressbar.md +0 -50
- package/content/components/prompttemplate.md +0 -49
- package/content/components/qrcode.md +0 -50
- package/content/components/radiogroup.md +0 -53
- package/content/components/rate.md +0 -53
- package/content/components/reasoningblock.md +0 -47
- package/content/components/relationgraph.md +0 -52
- package/content/components/resizable.md +0 -53
- package/content/components/result.md +0 -49
- package/content/components/scrollbar.md +0 -49
- package/content/components/searchinput.md +0 -51
- package/content/components/segmentedcontrol.md +0 -59
- package/content/components/select-searchable.md +0 -47
- package/content/components/select.md +0 -66
- package/content/components/sessionlist.md +0 -52
- package/content/components/sheetgrid.md +0 -44
- package/content/components/skeleton.md +0 -55
- package/content/components/slidecanvas.md +0 -44
- package/content/components/slider.md +0 -62
- package/content/components/sortablelist.md +0 -39
- package/content/components/space.md +0 -52
- package/content/components/sparkline.md +0 -52
- package/content/components/statcard-countdown.md +0 -39
- package/content/components/statcard.md +0 -56
- package/content/components/steps.md +0 -48
- package/content/components/switch.md +0 -50
- package/content/components/tabbar.md +0 -45
- package/content/components/table-v2.md +0 -40
- package/content/components/table.md +0 -66
- package/content/components/tabs.md +0 -56
- package/content/components/tag.md +0 -51
- package/content/components/tagsinput-v2.md +0 -39
- package/content/components/tagsinput.md +0 -54
- package/content/components/text.md +0 -45
- package/content/components/textarea.md +0 -57
- package/content/components/themeswitch.md +0 -69
- package/content/components/timeline.md +0 -50
- package/content/components/title.md +0 -45
- package/content/components/toast.md +0 -52
- package/content/components/toggle-togglegroup.md +0 -52
- package/content/components/togglegroup.md +0 -47
- package/content/components/toolcallcard.md +0 -51
- package/content/components/tooltip.md +0 -50
- package/content/components/tour.md +0 -50
- package/content/components/transfer.md +0 -52
- package/content/components/tree-v2.md +0 -39
- package/content/components/tree.md +0 -59
- package/content/components/treeselect.md +0 -54
- package/content/components/typography.md +0 -51
- package/content/components/videoplayer.md +0 -52
- package/content/components/virtuallist.md +0 -52
- package/content/components/virtualtable-v2.md +0 -39
- package/content/components/virtualtable.md +0 -55
- package/content/components/watermark.md +0 -53
- package/content/components/wave.md +0 -43
- package/content/guides/ai-chat-family.md +0 -24
- package/content/guides/choose.md +0 -67
- package/content/guides/component-model.md +0 -32
- package/content/guides/component-standards.md +0 -123
- package/content/guides/components-guide.md +0 -813
- package/content/guides/custom-component.md +0 -321
- package/content/guides/data-guide.md +0 -281
- package/content/guides/file-preview-family.md +0 -18
- package/content/guides/frontend.md +0 -968
- package/content/guides/layout-choice.md +0 -64
- package/content/guides/layout-guide.md +0 -241
- package/content/guides/middleware.md +0 -459
- package/content/guides/mobile-guide.md +0 -105
- package/content/guides/page-building.md +0 -98
- package/content/guides/production.md +0 -37
- package/content/guides/quality.md +0 -60
- package/content/guides/realtime-guide.md +0 -296
- package/content/guides/render-only.md +0 -44
- package/content/guides/saas-guide.md +0 -253
- package/content/guides/server-guide.md +0 -359
- package/content/guides/start.md +0 -41
- package/content/guides/styling.md +0 -154
- package/content/guides/ui-dom-guide.md +0 -157
- package/content/index.json +0 -4344
- package/content/index.md +0 -181
- package/content/layout/align.md +0 -20
- package/content/layout/anchor.md +0 -19
- package/content/layout/app-shell.md +0 -23
- package/content/layout/border.md +0 -20
- package/content/layout/center.md +0 -19
- package/content/layout/cluster.md +0 -19
- package/content/layout/container.md +0 -19
- package/content/layout/fill.md +0 -19
- package/content/layout/grid.md +0 -19
- package/content/layout/hidden.md +0 -22
- package/content/layout/layer.md +0 -19
- package/content/layout/position.md +0 -22
- package/content/layout/row.md +0 -23
- package/content/layout/safe-area.md +0 -20
- package/content/layout/scroll.md +0 -21
- package/content/layout/spacing.md +0 -22
- package/content/layout/split.md +0 -19
- package/content/layout/stack.md +0 -19
- package/content/layout/surface.md +0 -23
- package/content/layout/text.md +0 -22
- package/content/patterns/app-shell.md +0 -34
- package/content/patterns/dashboard.md +0 -36
- package/content/patterns/data-screen.md +0 -30
- package/content/patterns/detail-page.md +0 -31
- package/content/patterns/docs.md +0 -34
- package/content/patterns/focus-task.md +0 -34
- package/content/patterns/landing.md +0 -35
- package/content/patterns/list-page.md +0 -32
- package/content/patterns/mobile.md +0 -31
- package/content/patterns/settings-page.md +0 -33
- package/content/patterns/workspace.md +0 -32
- package/dist/cli/content-sync.test.d.ts +0 -1
- package/dist/cli/docs-cli.test.d.ts +0 -1
- package/dist/cli/docs.d.ts +0 -2
- package/dist/cli/docs.mjs +0 -10961
- package/dist/client/vdom/core/build.d.ts +0 -36
- package/dist/client/vdom/core/diff/children.d.ts +0 -29
- package/dist/client/vdom/core/diff/index.d.ts +0 -22
- package/dist/client/vdom/core/diff/output.d.ts +0 -30
- package/dist/client/vdom/core/diff/same.d.ts +0 -22
- package/dist/client/vdom/core/serve.d.ts +0 -75
- package/dist/client/vdom/core/ssr/index.d.ts +0 -25
- package/examples/apps/admin/README.md +0 -23
- package/examples/apps/admin/api.ts +0 -27
- package/examples/apps/admin/app.tsx +0 -144
- package/examples/apps/admin/main.tsx +0 -8
- package/examples/apps/admin/server.ts +0 -37
- package/examples/apps/auth/README.md +0 -23
- package/examples/apps/auth/api.ts +0 -49
- package/examples/apps/auth/app.tsx +0 -137
- package/examples/apps/auth/main.tsx +0 -8
- package/examples/apps/auth/server.ts +0 -37
- package/examples/apps/multi/README.md +0 -23
- package/examples/apps/multi/app.tsx +0 -83
- package/examples/apps/multi/main.tsx +0 -8
- package/examples/apps/multi/server.ts +0 -33
- package/examples/apps/todo/README.md +0 -23
- package/examples/apps/todo/api.ts +0 -26
- package/examples/apps/todo/app.tsx +0 -128
- package/examples/apps/todo/main.tsx +0 -9
- package/examples/apps/todo/server.ts +0 -39
- package/examples/hello-world/README.md +0 -9
- package/examples/hello-world/client.ts +0 -14
- package/examples/hello-world/routes.tsx +0 -26
- package/examples/hello-world/server.ts +0 -46
- package/examples/patterns/AppShell.tsx +0 -224
- package/examples/patterns/Dashboard.tsx +0 -153
- package/examples/patterns/DataScreen.tsx +0 -104
- package/examples/patterns/DetailPage.tsx +0 -79
- package/examples/patterns/Docs.tsx +0 -105
- package/examples/patterns/FocusTask.tsx +0 -67
- package/examples/patterns/Landing.tsx +0 -90
- package/examples/patterns/ListPage.tsx +0 -77
- package/examples/patterns/Mobile.tsx +0 -154
- package/examples/patterns/SettingsPage.tsx +0 -98
- package/examples/patterns/SplitWorkspace.tsx +0 -113
|
@@ -1,813 +0,0 @@
|
|
|
1
|
-
# 组件库使用示例速查
|
|
2
|
-
|
|
3
|
-
> 从 docs/components.md 迁移(content/ 文档库——随 npm 包发布,与框架版本同步)。
|
|
4
|
-
> 本页为叙述性指南——组件/能力逐项参考见 content/ 各域目录。
|
|
5
|
-
|
|
6
|
-
# 组件库(weifuwu/components)
|
|
7
|
-
|
|
8
|
-
129 个 HTML 原语组件。每个是 `async (initProps, ctx) => (props) => Promise<VNode>`(两阶段组件,与前端框架同一模型——外层工厂 + 内层 renderFn 强制异步),引用 `--wf-*` CSS 变量做主题。另含 `confirm()` / `toast()` 命令式中间件。
|
|
9
|
-
|
|
10
|
-
> **组件速查(weifuwu 组件 ↔ antd / Element Plus / shadcn-ui 对应 + 迁移示例)**:见 [`组件速查`](../../docs/components-map.md)——从其他组件库迁来的开发者按功能直接找对应组件。
|
|
11
|
-
> **自定义组件开发**:见 [custom-component.md](custom-component.md)——openPopup/useControlled/对话框/AI 组件/类型纪律逐步指南。
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { Button, Input, Table, Modal, Toast } from 'weifuwu/components'
|
|
15
|
-
import 'weifuwu/components/style.css' // 包含 Token + 66 布局原语 + 157 工具类 + 组件样式,一次性引入
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
### 使用示例
|
|
19
|
-
|
|
20
|
-
```tsx
|
|
21
|
-
// ├─ 按钮
|
|
22
|
-
<Button variant="primary" onClick={() => alert('提交')}>提交</Button>
|
|
23
|
-
<Button variant="ghost" loading>加载中</Button>
|
|
24
|
-
<Button variant="danger" size="lg" block>删除</Button>
|
|
25
|
-
|
|
26
|
-
// ├─ 输入框
|
|
27
|
-
<Input placeholder="请输入邮箱" />
|
|
28
|
-
<Input label="用户名" name="username" required error="必填" />
|
|
29
|
-
<Input type="password" hint="至少6位" />
|
|
30
|
-
<Input name="email" type="email" disabled placeholder="name@example.com" />
|
|
31
|
-
|
|
32
|
-
// ├─ 选择器(options 支持平铺项与分组混用:{ label, options } → optgroup)
|
|
33
|
-
<Select options={[{ value: 'a', label: '选项A' }]} placeholder="请选择" />
|
|
34
|
-
<Select searchable options={options} onChange={v => setVal(v)} />
|
|
35
|
-
<Select options={[{ label: '一线', options: [{ value: 'bj', label: '北京' }] }, { value: 'other', label: '其他' }]} />
|
|
36
|
-
|
|
37
|
-
// ├─ 复选框 / 开关 / 单选
|
|
38
|
-
<Checkbox checked={agree} onChange={setAgree} label="同意协议" />
|
|
39
|
-
<Switch checked={enabled} onChange={setEnabled} />
|
|
40
|
-
<RadioGroup options={[{ value: '1', label: '男' }, { value: '2', label: '女' }]} value={gender} />
|
|
41
|
-
|
|
42
|
-
// ├─ 表格
|
|
43
|
-
<Table columns={[{ key: 'id', label: 'ID', sortable: true }, { key: 'name', label: '名称' }]}
|
|
44
|
-
data={rows} sortKey="id" sortOrder="asc" onSort={(k, o) => setSort(k, o)} />
|
|
45
|
-
|
|
46
|
-
// ├─ 模态框 / 确认框 / 抽屉
|
|
47
|
-
<Modal open={show} title="提示" onClose={() => setShow(false)} width="500px" closable>
|
|
48
|
-
<p>确认删除?</p>
|
|
49
|
-
</Modal>
|
|
50
|
-
<Confirm open={confirming} message="确定删除?" variant="danger" onConfirm={doDelete} onCancel={() => setConfirming(false)} />
|
|
51
|
-
// 命令式:await ctx.confirm?.('确定删除?') —— 组件里直接调用
|
|
52
|
-
<Drawer open={open} title="详情" onClose={() => setOpen(false)} position="right">内容</Drawer>
|
|
53
|
-
|
|
54
|
-
// ├─ 消息提示
|
|
55
|
-
<Toast toasts={items} position="top-right" max={5} onRemove={id => remove(id)} />
|
|
56
|
-
<Alert variant="warning" closable>注意:磁盘空间不足</Alert>
|
|
57
|
-
|
|
58
|
-
// ├─ 标签 / 徽标 / 头像
|
|
59
|
-
<Badge variant="primary">消息</Badge>
|
|
60
|
-
<Badge variant="success" dot>通过</Badge>
|
|
61
|
-
<Tag variant="primary" closable onClose={() => {}}>标签</Tag>
|
|
62
|
-
<Avatar name="张三" size="lg" />
|
|
63
|
-
|
|
64
|
-
// ├─ 卡片 / 统计卡片
|
|
65
|
-
<Card variant="outlined" padding="md">卡片内容</Card>
|
|
66
|
-
<StatCard label="总用户" value="1,234" trend="up" trendLabel="12%" />
|
|
67
|
-
|
|
68
|
-
// ├─ 标签页 / 下拉菜单
|
|
69
|
-
<Tabs items={[{ key: 'a', label: '标签A' }, { key: 'b', label: '标签B' }]} active="a" onChange={setTab} />
|
|
70
|
-
<Dropdown items={[{ label: '编辑', onClick: () => {} }, { label: '删除', variant: 'danger' }]}>操作</Dropdown>
|
|
71
|
-
|
|
72
|
-
// ├─ 分页 / 步骤条
|
|
73
|
-
<Pagination total={100} page={1} pageSize={10} onChange={setPage} />
|
|
74
|
-
<Steps items={[{ key: 's1', label: '第一步' }, { key: 's2', label: '第二步' }]} current={1} />
|
|
75
|
-
|
|
76
|
-
// ├─ 滑块 / 进度条
|
|
77
|
-
<Slider min={0} max={100} value={50} onChange={setValue} />
|
|
78
|
-
<ProgressBar value={75} label="75%" />
|
|
79
|
-
|
|
80
|
-
// ├─ 面包屑 / 分割线
|
|
81
|
-
<Breadcrumb items={[{ label: '首页' }, { label: '用户管理' }]} />
|
|
82
|
-
<Divider />
|
|
83
|
-
<Divider>分割文字</Divider>
|
|
84
|
-
|
|
85
|
-
// ├─ 加载 / 空状态 / 骨架屏
|
|
86
|
-
<Loading text="加载中..." />
|
|
87
|
-
<EmptyState text="暂无数据" hint="请先创建一条记录"><Button>新建</Button></EmptyState>
|
|
88
|
-
<Skeleton variant="text" lines={3} />
|
|
89
|
-
<Skeleton variant="table" lines={5} cols={4} />
|
|
90
|
-
<Skeleton variant="avatar" />
|
|
91
|
-
<Skeleton variant="image" />
|
|
92
|
-
|
|
93
|
-
// ├─ 表单验证
|
|
94
|
-
<Form validation={{ email: [{ required: true, message: '请输入邮箱' }] }}
|
|
95
|
-
onSubmit={values => ctx.api?.post('/login', values)} // ctx.api 由中间件注入
|
|
96
|
-
onError={errors => setErrors(errors)}>
|
|
97
|
-
<Field label="邮箱" error={errors.email}>
|
|
98
|
-
<Input name="email" />
|
|
99
|
-
</Field>
|
|
100
|
-
<Button type="submit">登录</Button>
|
|
101
|
-
</Form>
|
|
102
|
-
|
|
103
|
-
// ├─ 新增批次组件(全量实现)
|
|
104
|
-
<Rate value={3} onChange={setRate} /> // 评分
|
|
105
|
-
<ToggleGroup type="single" options={toolbar} value={fmt} /> // 工具栏切换
|
|
106
|
-
<CheckboxGroup options={members} value={selected} onChange={setSelected} /> // 多选列表
|
|
107
|
-
<PinInput length={6} value={code} onChange={setCode} /> // 验证码
|
|
108
|
-
<CopyButton value="https://weifuwu.dev" label="复制" /> // 复制
|
|
109
|
-
<ColorPicker value={color} showInput onChange={setColor} /> // 颜色
|
|
110
|
-
<Notification /> + notification.success({ title, description }) // 队列通知
|
|
111
|
-
<Collapse items={docs} active={open} /> // 行内折叠
|
|
112
|
-
<Tree data={orgTree} checkable checkedKeys={keys} /> // 树形(父子联动)
|
|
113
|
-
<Cascader options={regions} value={['zj','hz']} /> // 级联选择
|
|
114
|
-
<Transfer data={members} targetKeys={selected} /> // 穿梭框
|
|
115
|
-
<Command items={commands} open={open} onOpenChange={setOpen} /> // ⌘K 命令面板
|
|
116
|
-
<Carousel autoplay>{slides}</Carousel> // 轮播
|
|
117
|
-
<Resizable defaultSize={180}>…</Resizable> // 拖拽分割
|
|
118
|
-
<Calendar month={5} year={2025} events={events} /> // 月历
|
|
119
|
-
<Watermark text="内部资料">…</Watermark> // 水印
|
|
120
|
-
<VirtualList height={400} itemHeight={36} items={rows} renderItem={render} /> // 虚拟列表
|
|
121
|
-
<QRCode value="https://weifuwu.dev" size={128} /> // 二维码(自研编码)
|
|
122
|
-
<Img src="photo.png" preview /> // 图片点击放大
|
|
123
|
-
<BackTop /> <Affix offsetTop={64}>…</Affix> // 回顶 / 固定
|
|
124
|
-
<HoverCard content={<UserCard />}>…</HoverCard> // 悬停富内容
|
|
125
|
-
<Mentions options={users} value={text} /> // @提及
|
|
126
|
-
<ContextMenu items={actions}>…</ContextMenu> // 右键菜单
|
|
127
|
-
<Menubar menus={menus} /> // 水平菜单
|
|
128
|
-
<InfiniteScroll hasMore onLoadMore>…</InfiniteScroll> // 无限滚动
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
> 所有组件引用 `--wf-*` CSS 变量做主题,详见下文的「样式定制指南」。
|
|
132
|
-
|
|
133
|
-
### 生命周期映射
|
|
134
|
-
|
|
135
|
-
组件没有生命周期函数。每个阶段对应到代码的明确位置:
|
|
136
|
-
|
|
137
|
-
```
|
|
138
|
-
mount ──────────────────────────────────────────
|
|
139
|
-
const Counter = async (_init, ctx) => { ← mount(只一次,可 await)
|
|
140
|
-
let count = 0 ← 初始化状态
|
|
141
|
-
return async (props) => { ← renderFn(强制异步)
|
|
142
|
-
// ... ← 每次 dirty/props 变化执行
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
ref ────────────────────────────────────────────
|
|
147
|
-
h('div', {
|
|
148
|
-
ref: (el) => {
|
|
149
|
-
if (el) { /* 元素已创建 */ } ← 相当于 onmounted
|
|
150
|
-
else { /* 元素已移除 */ } ← 相当于 onunmount
|
|
151
|
-
}
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
props 变化 ─────────────────────────────────────
|
|
155
|
-
return async (props) => {
|
|
156
|
-
// 每次 render 都收到最新 props ← 相当于 onupdate
|
|
157
|
-
if (props.value !== prevValue) { ... }
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
| 旧概念 | 新写法 |
|
|
162
|
-
|--------|--------|
|
|
163
|
-
| `onmount` | mount 外层函数直接写 |
|
|
164
|
-
| `onmounted` | `ref` 的 `if (el)` 分支 |
|
|
165
|
-
| `onunmount` | `ref` 的 `else` 分支 |
|
|
166
|
-
| `onupdate` | render 内层函数收新 props 自行比较 |
|
|
167
|
-
| `全局刷新` | `ctx.ui.render(['_wf_root'])` |
|
|
168
|
-
| `局部刷新` | `ctx.ui.render()` 或 `$.x = val` |
|
|
169
|
-
| `跨组件刷新` | `ctx.ui.selfId('name')` + `render(['name'])` |
|
|
170
|
-
|
|
171
|
-
## 通用约定(所有组件一致)
|
|
172
|
-
|
|
173
|
-
### 受控模式
|
|
174
|
-
|
|
175
|
-
| 组件类型 | 受控 prop | 必须配回调 |
|
|
176
|
-
|----------|-----------|-----------|
|
|
177
|
-
| 开关/勾选(Checkbox/Switch/RadioGroup) | `checked` | `onChange` |
|
|
178
|
-
| 输入(Input/Select/DatePicker/Textarea) | `value` | `onChange` / `onInput` |
|
|
179
|
-
| 标签页/折叠(Tabs/Collapse) | `active` | `onChange` |
|
|
180
|
-
| 弹层(Modal/Drawer/Dropdown/Popover) | `open` | `onClose` / `onOpenChange` |
|
|
181
|
-
| 树/级联/穿梭(Tree/Cascader/Transfer) | `checkedKeys`/`value`/`targetKeys` | `onChange` |
|
|
182
|
-
| 月历(Calendar) | `month`/`year` | `onMonthChange` |
|
|
183
|
-
|
|
184
|
-
**规则**:传受控 props 而不传回调时,交互**静默失效**——组件 `console.warn` 明确提示(Collapse/Tree/Calendar/Cascader/Dropdown 已有防护)。非受控(不传受控 props)即可直接点击。
|
|
185
|
-
|
|
186
|
-
### size 变体
|
|
187
|
-
|
|
188
|
-
- `sm` / `md` / `lg`(Button/Avatar/Input 族)。未提供 size 的组件使用默认尺寸(CSS `--wf-control-pad-*` 驱动)。
|
|
189
|
-
- 触屏(coarse pointer)自动 44px 命中区,不受 size 影响。
|
|
190
|
-
|
|
191
|
-
### 事件命名
|
|
192
|
-
|
|
193
|
-
| 语义 | 命名 |
|
|
194
|
-
|------|------|
|
|
195
|
-
| 值变化(受控) | `onChange` |
|
|
196
|
-
| 原生输入 | `onInput` |
|
|
197
|
-
| 列表选中 | `onSelect` |
|
|
198
|
-
| 弹层开关 | `onOpenChange`(弹层)/ `onClose`(对话框) |
|
|
199
|
-
| 表格排序 | `onSort` |
|
|
200
|
-
|
|
201
|
-
### 命令式 API(无需组件)
|
|
202
|
-
|
|
203
|
-
`confirm()` / `toast()` / `notification.success()`——组件内 `ctx.confirm?.('确定?')` 直接可用(中间件注入)。
|
|
204
|
-
|
|
205
|
-
## 关键组件 Props 参考
|
|
206
|
-
> 从组件 TS 类型自动提取(`src/components/*/*.ts` 的 `interface XxxProps`)。
|
|
207
|
-
> 完整 props 以 TS 类型为准——`tsc` 编译期校验;此处为速查。受控约定:传受控 props 必须配回调(缺回调运行期 warn)。
|
|
208
|
-
|
|
209
|
-
### Button(表单/通用)
|
|
210
|
-
| Prop | 类型 | 说明 |
|
|
211
|
-
|------|------|------|
|
|
212
|
-
| `variant` | `'primary' \| 'secondary' \| 'ghost' \| 'danger'` | — |
|
|
213
|
-
| `size` | `'sm' \| 'md' \| 'lg'` | — |
|
|
214
|
-
| `block` | `boolean` | — |
|
|
215
|
-
| `loading` | `boolean` | — |
|
|
216
|
-
| `disabled` | `boolean` | — |
|
|
217
|
-
| `type` | `'button' \| 'submit'` | — |
|
|
218
|
-
| `title` | `string` | — |
|
|
219
|
-
| `class` | `string` | 透传原生 class(覆盖默认 wf-btn 组合) |
|
|
220
|
-
| `onClick` | `(e: MouseEvent) => void` | — |
|
|
221
|
-
| `children` | `any` | — |
|
|
222
|
-
|
|
223
|
-
### Input(表单核心)
|
|
224
|
-
| Prop | 类型 | 说明 |
|
|
225
|
-
|------|------|------|
|
|
226
|
-
| `label` | `string` | — |
|
|
227
|
-
| `name` | `string` | — |
|
|
228
|
-
| `type` | `'text' \| 'email' \| 'password' \| 'number' \| 'url' \| 'date' \| 'tel' \| 'time' \| 'color'` | — |
|
|
229
|
-
| `value` | `string` | — |
|
|
230
|
-
| `placeholder` | `string` | — |
|
|
231
|
-
| `required` | `boolean` | — |
|
|
232
|
-
| `disabled` | `boolean` | — |
|
|
233
|
-
| `error` | `string` | — |
|
|
234
|
-
| `hint` | `string` | — |
|
|
235
|
-
| `variant` | `'default' \| 'borderless'` | 边框变体:borderless 用于可编辑标题/内联编辑(hover/focus 才显边框) |
|
|
236
|
-
| `onInput` | `(e: Event) => void` | — |
|
|
237
|
-
| `onChange` | `(e: Event) => void` | — |
|
|
238
|
-
| `min` | `string \| number` | 原生 input 属性透传(type=number 时 min/max/step 等) |
|
|
239
|
-
| `max` | `string \| number` | — |
|
|
240
|
-
| `step` | `string \| number` | — |
|
|
241
|
-
| `key` | `string]: any` | — |
|
|
242
|
-
|
|
243
|
-
### Textarea(表单核心)
|
|
244
|
-
| Prop | 类型 | 说明 |
|
|
245
|
-
|------|------|------|
|
|
246
|
-
| `label` | `string` | — |
|
|
247
|
-
| `value` | `string` | — |
|
|
248
|
-
| `placeholder` | `string` | — |
|
|
249
|
-
| `required` | `boolean` | — |
|
|
250
|
-
| `disabled` | `boolean` | — |
|
|
251
|
-
| `error` | `string` | — |
|
|
252
|
-
| `hint` | `string` | — |
|
|
253
|
-
| `rows` | `number` | — |
|
|
254
|
-
| `maxLength` | `number` | 最大字符数(同时限制输入) |
|
|
255
|
-
| `showCount` | `boolean` | 显示字数统计(右下角;配合受控 value 实时更新) |
|
|
256
|
-
| `onInput` | `(e: Event) => void` | — |
|
|
257
|
-
|
|
258
|
-
### Select(表单选择)
|
|
259
|
-
| Prop | 类型 | 说明 |
|
|
260
|
-
|------|------|------|
|
|
261
|
-
| `label` | `string` | — |
|
|
262
|
-
| `value` | `string \| string[]` | — |
|
|
263
|
-
| `options` | `SelectOption[]` | — |
|
|
264
|
-
| `placeholder` | `string` | — |
|
|
265
|
-
| `required` | `boolean` | — |
|
|
266
|
-
| `disabled` | `boolean` | — |
|
|
267
|
-
| `error` | `string` | — |
|
|
268
|
-
| `onChange` | `(value: string \| string[]) => void` | — |
|
|
269
|
-
| `children` | `any` | — |
|
|
270
|
-
| `searchable` | `boolean` | 启用搜索过滤 |
|
|
271
|
-
| `multiple` | `boolean` | 多选模式(searchable 下生效;value/onChange 为数组) |
|
|
272
|
-
| `onSearch` | `(keyword: string) => SelectOption[] \| Promise<SelectOption[]>` | 异步搜索回调,返回值作为新选项列表 |
|
|
273
|
-
|
|
274
|
-
### Checkbox(表单选择)
|
|
275
|
-
| Prop | 类型 | 说明 |
|
|
276
|
-
|------|------|------|
|
|
277
|
-
| `label` | `string` | — |
|
|
278
|
-
| `checked` | `boolean` | — |
|
|
279
|
-
| `disabled` | `boolean` | — |
|
|
280
|
-
| `onChange` | `(checked: boolean) => void` | — |
|
|
281
|
-
|
|
282
|
-
### Switch(表单选择)
|
|
283
|
-
| Prop | 类型 | 说明 |
|
|
284
|
-
|------|------|------|
|
|
285
|
-
| `label` | `string` | — |
|
|
286
|
-
| `checked` | `boolean` | — |
|
|
287
|
-
| `disabled` | `boolean` | — |
|
|
288
|
-
| `onChange` | `(checked: boolean) => void` | — |
|
|
289
|
-
|
|
290
|
-
### RadioGroup(表单选择)
|
|
291
|
-
| Prop | 类型 | 说明 |
|
|
292
|
-
|------|------|------|
|
|
293
|
-
| `name` | `string` | — |
|
|
294
|
-
| `value` | `string` | — |
|
|
295
|
-
| `options` | `RadioOption[]` | — |
|
|
296
|
-
| `inline` | `boolean` | — |
|
|
297
|
-
| `onChange` | `(value: string) => void` | — |
|
|
298
|
-
|
|
299
|
-
### DatePicker(表单选择)
|
|
300
|
-
| Prop | 类型 | 说明 |
|
|
301
|
-
|------|------|------|
|
|
302
|
-
| `mode` | `DatePickerMode` | — |
|
|
303
|
-
| `value` | `string` | — |
|
|
304
|
-
| `onChange` | `(value: string) => void` | — |
|
|
305
|
-
| `placeholder` | `string` | — |
|
|
306
|
-
| `disabled` | `boolean` | — |
|
|
307
|
-
| `error` | `string` | 错误态——输入框错误样式 + aria-invalid(F2 状态矩阵) |
|
|
308
|
-
|
|
309
|
-
### Form(表单增强)
|
|
310
|
-
| Prop | 类型 | 说明 |
|
|
311
|
-
|------|------|------|
|
|
312
|
-
| `onSubmit` | `(values: Record<string, any>) => void \| Promise<void>` | 提交回调,接收字段名→值的对象 |
|
|
313
|
-
| `validation` | `Record<string, ValidationRule[]>` | 验证规则:字段名 → 规则数组 |
|
|
314
|
-
| `onError` | `(errors: Record<string, string>) => void` | 验证失败时回调,接收字段名→错误消息的对象 |
|
|
315
|
-
| `children` | `any` | — |
|
|
316
|
-
|
|
317
|
-
### Field(表单增强)
|
|
318
|
-
| Prop | 类型 | 说明 |
|
|
319
|
-
|------|------|------|
|
|
320
|
-
| `label` | `string` | — |
|
|
321
|
-
| `required` | `boolean` | — |
|
|
322
|
-
| `error` | `string` | — |
|
|
323
|
-
| `hint` | `string` | — |
|
|
324
|
-
| `children` | `any` | — |
|
|
325
|
-
|
|
326
|
-
### Table(数据展示)
|
|
327
|
-
| Prop | 类型 | 说明 |
|
|
328
|
-
|------|------|------|
|
|
329
|
-
| `data` | `any[]` | — |
|
|
330
|
-
| `columns` | `TableColumn[]` | — |
|
|
331
|
-
| `onRowClick` | `(row: any, index: number) => void` | — |
|
|
332
|
-
| `sortKey` | `string` | 当前排序列的 key |
|
|
333
|
-
| `sortOrder` | `'asc' \| 'desc'` | 当前排序方向 |
|
|
334
|
-
| `onSort` | `(key: string, order: 'asc' \| 'desc') => void` | 排序变化回调 |
|
|
335
|
-
| `rowSelection` | `TableRowSelection` | 行选择(受控) |
|
|
336
|
-
| `emptyText` | `string` | 数据为空时显示的文本 |
|
|
337
|
-
| `minWidth` | `string` | 表格最小宽度(窄屏横向滚动,如 '720px') |
|
|
338
|
-
| `loading` | `boolean` | 加载中:保留表头,渲染骨架行 |
|
|
339
|
-
| `loadingRows` | `number` | 骨架行数,默认 3 |
|
|
340
|
-
|
|
341
|
-
### Modal(数据反馈)
|
|
342
|
-
| Prop | 类型 | 说明 |
|
|
343
|
-
|------|------|------|
|
|
344
|
-
| `open` | `boolean` | — |
|
|
345
|
-
| `title` | `string` | — |
|
|
346
|
-
| `onClose` | `() => void` | — |
|
|
347
|
-
| `children` | `any` | — |
|
|
348
|
-
| `footer` | `any` | — |
|
|
349
|
-
| `width` | `string` | 自定义宽度,如 '500px'、'80%',默认 400px |
|
|
350
|
-
| `closable` | `boolean` | 是否显示关闭按钮,默认 true |
|
|
351
|
-
| `maskClosable` | `boolean` | 点击遮罩是否关闭,默认 true(危险确认应设 false) |
|
|
352
|
-
|
|
353
|
-
### Drawer(数据反馈)
|
|
354
|
-
| Prop | 类型 | 说明 |
|
|
355
|
-
|------|------|------|
|
|
356
|
-
| `open` | `boolean` | — |
|
|
357
|
-
| `title` | `string` | — |
|
|
358
|
-
| `position` | `DrawerPosition` | — |
|
|
359
|
-
| `onClose` | `() => void` | — |
|
|
360
|
-
| `children` | `any` | — |
|
|
361
|
-
| `footer` | `any` | — |
|
|
362
|
-
|
|
363
|
-
### Confirm(数据反馈)
|
|
364
|
-
| Prop | 类型 | 说明 |
|
|
365
|
-
|------|------|------|
|
|
366
|
-
| `open` | `boolean` | — |
|
|
367
|
-
| `title` | `string` | — |
|
|
368
|
-
| `message` | `any` | 提示内容(文本或任意 VNode) |
|
|
369
|
-
| `confirmText` | `string` | — |
|
|
370
|
-
| `cancelText` | `string` | — |
|
|
371
|
-
| `variant` | `'primary' \| 'danger'` | — |
|
|
372
|
-
| `width` | `string` | 对话框宽度,如 '500px'、'80%',默认 Modal 的 400px |
|
|
373
|
-
| `maskClosable` | `boolean` | 遮罩点击是否取消(默认 false:危险操作防误触;显式传 true 可恢复) |
|
|
374
|
-
| `onConfirm` | `() => void` | — |
|
|
375
|
-
| `onCancel` | `() => void` | — |
|
|
376
|
-
|
|
377
|
-
### Toast(数据反馈)
|
|
378
|
-
| Prop | 类型 | 说明 |
|
|
379
|
-
|------|------|------|
|
|
380
|
-
| `toasts` | `ToastItem[]` | — |
|
|
381
|
-
| `onRemove` | `(id: string) => void` | — |
|
|
382
|
-
| `position` | `ToastPosition` | 容器位置,默认 top-right |
|
|
383
|
-
| `duration` | `number` | 全局默认自动消失时间(ms),0 = 不自动消失,默认 0 |
|
|
384
|
-
| `max` | `number` | 最大显示条数,超出时移除最早条目,默认 0 = 不限制 |
|
|
385
|
-
|
|
386
|
-
### Tooltip(数据反馈)
|
|
387
|
-
| Prop | 类型 | 说明 |
|
|
388
|
-
|------|------|------|
|
|
389
|
-
| `content` | `string` | — |
|
|
390
|
-
| `position` | `TooltipPosition` | — |
|
|
391
|
-
| `children` | `any` | — |
|
|
392
|
-
| `disabled` | `boolean` | — |
|
|
393
|
-
|
|
394
|
-
### Popover(数据反馈)
|
|
395
|
-
| Prop | 类型 | 说明 |
|
|
396
|
-
|------|------|------|
|
|
397
|
-
| `content` | `any` | — |
|
|
398
|
-
| `trigger` | `'click' \| 'hover'` | — |
|
|
399
|
-
| `position` | `PopoverPosition` | — |
|
|
400
|
-
| `open` | `boolean` | — |
|
|
401
|
-
| `onOpenChange` | `(open: boolean) => void` | — |
|
|
402
|
-
| `disabled` | `boolean` | — |
|
|
403
|
-
| `children` | `any` | — |
|
|
404
|
-
|
|
405
|
-
### Dropdown(导航组件)
|
|
406
|
-
| Prop | 类型 | 说明 |
|
|
407
|
-
|------|------|------|
|
|
408
|
-
| `trigger` | `any` | — |
|
|
409
|
-
| `items` | `DropdownItem[]` | — |
|
|
410
|
-
| `open` | `boolean` | — |
|
|
411
|
-
| `onOpenChange` | `(open: boolean) => void` | 关闭回调(面板内 Escape / 外部点击) |
|
|
412
|
-
|
|
413
|
-
### Tabs(导航组件)
|
|
414
|
-
| Prop | 类型 | 说明 |
|
|
415
|
-
|------|------|------|
|
|
416
|
-
| `items` | `TabItem[]` | — |
|
|
417
|
-
| `active` | `string` | — |
|
|
418
|
-
| `onChange` | `(key: string) => void` | — |
|
|
419
|
-
|
|
420
|
-
### Pagination(导航组件)
|
|
421
|
-
| Prop | 类型 | 说明 |
|
|
422
|
-
|------|------|------|
|
|
423
|
-
| `total` | `number` | — |
|
|
424
|
-
| `page` | `number` | — |
|
|
425
|
-
| `pageSize` | `number` | — |
|
|
426
|
-
| `onChange` | `(page: number) => void` | — |
|
|
427
|
-
|
|
428
|
-
### Tree(新增批次)
|
|
429
|
-
| Prop | 类型 | 说明 |
|
|
430
|
-
|------|------|------|
|
|
431
|
-
| `data` | `TreeNode[]` | — |
|
|
432
|
-
| `selectedKeys` | `string[]` | 受控选中 keys |
|
|
433
|
-
| `onSelect` | `(keys: string[]) => void` | — |
|
|
434
|
-
| `expandedKeys` | `string[]` | 受控展开 keys |
|
|
435
|
-
| `onExpand` | `(keys: string[]) => void` | — |
|
|
436
|
-
| `checkable` | `boolean` | 勾选模式(父子联动,antd 非 strict 语义) |
|
|
437
|
-
| `checkedKeys` | `string[]` | — |
|
|
438
|
-
| `onCheck` | `(keys: string[]) => void` | — |
|
|
439
|
-
| `className` | `string` | — |
|
|
440
|
-
|
|
441
|
-
### Cascader(新增批次)
|
|
442
|
-
| Prop | 类型 | 说明 |
|
|
443
|
-
|------|------|------|
|
|
444
|
-
| `options` | `CascaderOption[]` | — |
|
|
445
|
-
| `value` | `string[]` | 选中路径(数组,如 ['zj','hz','xh']) |
|
|
446
|
-
| `onChange` | `(value: string[]) => void` | — |
|
|
447
|
-
| `placeholder` | `string` | — |
|
|
448
|
-
| `disabled` | `boolean` | — |
|
|
449
|
-
| `error` | `string` | — |
|
|
450
|
-
| `label` | `string` | — |
|
|
451
|
-
|
|
452
|
-
### Transfer(新增批次)
|
|
453
|
-
| Prop | 类型 | 说明 |
|
|
454
|
-
|------|------|------|
|
|
455
|
-
| `data` | `TransferItem[]` | — |
|
|
456
|
-
| `targetKeys` | `string[]` | 目标侧已选 keys |
|
|
457
|
-
| `onChange` | `(targetKeys: string[]) => void` | — |
|
|
458
|
-
| `titles` | `[string, string]` | — |
|
|
459
|
-
| `size` | `'sm' \| 'md' \| 'lg'` | — |
|
|
460
|
-
| `disabled` | `boolean` | — |
|
|
461
|
-
|
|
462
|
-
### Carousel(新增批次)
|
|
463
|
-
| Prop | 类型 | 说明 |
|
|
464
|
-
|------|------|------|
|
|
465
|
-
| `children` | `any[]` | — |
|
|
466
|
-
| `autoplay` | `boolean` | 自动播放 |
|
|
467
|
-
| `interval` | `number` | 自动播放间隔(ms),默认 3000 |
|
|
468
|
-
| `showArrows` | `boolean` | — |
|
|
469
|
-
| `showDots` | `boolean` | — |
|
|
470
|
-
| `loop` | `boolean` | 循环播放(尾 → 头),默认 true |
|
|
471
|
-
| `className` | `string` | — |
|
|
472
|
-
|
|
473
|
-
### Calendar(新增批次)
|
|
474
|
-
| Prop | 类型 | 说明 |
|
|
475
|
-
|------|------|------|
|
|
476
|
-
| `events` | `CalendarEvent[]` | — |
|
|
477
|
-
| `month` | `number` | 受控年月:month 0-11,year 四位数 |
|
|
478
|
-
| `year` | `number` | — |
|
|
479
|
-
| `onMonthChange` | `(month: number, year: number) => void` | — |
|
|
480
|
-
| `onSelectDate` | `(date: string) => void` | — |
|
|
481
|
-
| `selectedDate` | `string` | — |
|
|
482
|
-
|
|
483
|
-
### AiChat(AI 交互)
|
|
484
|
-
| Prop | 类型 | 说明 |
|
|
485
|
-
|------|------|------|
|
|
486
|
-
| `chat` | `UseChatHandle` | ctx.ui.useChat() 返回的会话 handle(同一 $,状态变化自动重渲染) |
|
|
487
|
-
| `maxHeight` | `string` | 消息列表最大高度(默认 '70vh') |
|
|
488
|
-
| `labels` | `Partial<AiChatLabels>` | 界面文案覆盖 |
|
|
489
|
-
| `renderMessage` | `(msg: UiMessage) => any` | 自定义气泡渲染逃生舱(默认纯文本) |
|
|
490
|
-
| `renderToolArgs` | `(args: Record<string, unknown>) => any` | 工具参数渲染(透传 ToolCallCard) |
|
|
491
|
-
| `raiseOnKeyboard` | `boolean` | 键盘弹起时输入区 fixed 抬升(全屏 chat 布局用;内联卡片默认 false——原生聚焦滚动已够) |
|
|
492
|
-
|
|
493
|
-
### FileUpload(表单增强)
|
|
494
|
-
| Prop | 类型 | 说明 |
|
|
495
|
-
|------|------|------|
|
|
496
|
-
| `accept` | `string` | — |
|
|
497
|
-
| `multiple` | `boolean` | — |
|
|
498
|
-
| `maxSize` | `number` | — |
|
|
499
|
-
| `disabled` | `boolean` | — |
|
|
500
|
-
| `error` | `string` | — |
|
|
501
|
-
| `hint` | `string` | — |
|
|
502
|
-
| `value` | `File[]` | — |
|
|
503
|
-
| `onChange` | `(files: File[]) => void` | — |
|
|
504
|
-
| `children` | `any` | — |
|
|
505
|
-
|
|
506
|
-
### Slider(表单选择)
|
|
507
|
-
| Prop | 类型 | 说明 |
|
|
508
|
-
|------|------|------|
|
|
509
|
-
| `label` | `string` | — |
|
|
510
|
-
| `value` | `number \| string` | — |
|
|
511
|
-
| `min` | `number` | — |
|
|
512
|
-
| `max` | `number` | — |
|
|
513
|
-
| `step` | `number` | — |
|
|
514
|
-
| `onChange` | `(value: number) => void` | — |
|
|
515
|
-
|
|
516
|
-
## 组件列表
|
|
517
|
-
|
|
518
|
-
### 表单核心
|
|
519
|
-
|
|
520
|
-
| 组件 | 导入名 | 关键 Props | 说明 |
|
|
521
|
-
|-----|--------|-----------|------|
|
|
522
|
-
| Button | `Button` | `variant`, `size`, `loading`, `disabled`, `block`, `type` | 按钮 |
|
|
523
|
-
| Input | `Input` | `label`, `name`, `type`, `value`, `placeholder`, `required`, `disabled`, `error`, `hint`, `onInput`, `onChange` | 输入框 |
|
|
524
|
-
| Textarea | `Textarea` | `rows`, `maxLength`, `showCount`, `error` | 文本域 |
|
|
525
|
-
| Select | `Select` | `options: SelectOption[]`, `placeholder`, `searchable` | 下拉选择 |
|
|
526
|
-
|
|
527
|
-
### 表单选择
|
|
528
|
-
|
|
529
|
-
| 组件 | 导入名 | 关键 Props | 说明 |
|
|
530
|
-
|-----|--------|-----------|------|
|
|
531
|
-
| Checkbox | `Checkbox` | `checked`, `label`, `onChange` | 复选框 |
|
|
532
|
-
| Switch | `Switch` | `checked`, `label`, `onChange` | 开关 |
|
|
533
|
-
| RadioGroup | `RadioGroup` | `options: RadioOption[]`, `value`, `name` | 单选组 |
|
|
534
|
-
| Slider | `Slider` | `min`, `max`, `step`, `value`, `onChange` | 滑块 |
|
|
535
|
-
|
|
536
|
-
### 表单增强
|
|
537
|
-
|
|
538
|
-
| 组件 | 导入名 | 关键 Props | 说明 |
|
|
539
|
-
|-----|--------|-----------|------|
|
|
540
|
-
| Form | `Form` | `onSubmit`, `validation` | 表单容器 |
|
|
541
|
-
| Field | `Field` | `label`, `error`, `required`, `hint` | 字段包装 |
|
|
542
|
-
| FileUpload | `FileUpload` | `accept`, `multiple`, `maxSize`, `onChange` | 文件上传 |
|
|
543
|
-
| SearchInput | `SearchInput` | `value`, `placeholder`, `onInput`, `onClear` | 搜索框 |
|
|
544
|
-
| SegmentedControl | `SegmentedControl` | `options: SegmentedOption[]`, `value`, `onChange`, `size` | 分段选择器 |
|
|
545
|
-
| ProgressBar | `ProgressBar` | `value`, `max`, `label`, `showValue` | 进度条 |
|
|
546
|
-
| InputNumber | `InputNumber` | `value`, `min`, `max`, `step`, `precision`, `onChange` | 数字输入(增减按钮) |
|
|
547
|
-
| PasswordInput | `PasswordInput` | `value`, `onInput`, `autoComplete` | 密码输入(可见性切换) |
|
|
548
|
-
| TagsInput | `TagsInput` | `value: string[]`, `maxTags`, `allowDuplicates` | 标签输入(中文输入法感知) |
|
|
549
|
-
|
|
550
|
-
### 数据展示
|
|
551
|
-
|
|
552
|
-
| 组件 | 导入名 | 关键 Props | 说明 |
|
|
553
|
-
|-----|--------|-----------|------|
|
|
554
|
-
| Table | `Table` | `columns: TableColumn[]`, `data`, `loading`, `sortKey`, `sortOrder`, `onSort`, `onRowClick` | 表格 |
|
|
555
|
-
| Card | `Card` | `variant`, `outlined`, `padding`, `clickable`, `hover`, `active`, `onClick` | 卡片 |
|
|
556
|
-
| Badge | `Badge` | `variant: BadgeVariant`, `dot` | 徽标 |
|
|
557
|
-
| Tag | `Tag` | `variant: 'default'\|'primary'\|'success'\|'danger'`, `closable`, `onClose` | 标签 |
|
|
558
|
-
| Avatar | `Avatar` | `src`, `name`, `size`, `color` | 头像 |
|
|
559
|
-
| AvatarGroup | `AvatarGroup` | `items`, `max`, `size` | 头像组(堆叠 + 溢出 +N) |
|
|
560
|
-
| Timeline | `Timeline` | `items: TimelineItem[]`, `mode`, `reverse` | 时间线(执行日志/历史) |
|
|
561
|
-
| Descriptions | `Descriptions` | `items: DescriptionItem[]`, `column`, `bordered` | 描述列表(详情页字段) |
|
|
562
|
-
| Markdown | `Markdown` | `content` | AI 回复渲染(安全子集 parser) |
|
|
563
|
-
| CodeBlock | `CodeBlock` | `code`, `lang`, `title` | 代码块(语言标签 + 复制) |
|
|
564
|
-
| Highlight | `Highlight` | `text`, `query: string \| string[]` | 搜索词高亮(mark) |
|
|
565
|
-
| List | `List` | `items`, `renderItem`, `keyBy?`, `divided`, `header/footer/empty` | 通用列表——`keyBy`(可选)自定义项 key:renderItem 渲染有内部状态的组件且列表动态增删/重排时传身份跟随内容的 key(默认数组下标 = 位置身份) |
|
|
566
|
-
| Result | `Result` | `status`, `title`, `desc`, `extra` | 结果页(成功/失败/警告/信息) |
|
|
567
|
-
| Icon | `Icon` | `name: IconName`, `size` | 图标(内置 25 个 stroke 图标,currentColor 随字号) |
|
|
568
|
-
| StatCard | `StatCard` | `label`, `value`, `trend: 'up'\|'down'`, `trendLabel`, `icon`, `animate` | 统计卡片 |
|
|
569
|
-
| PageHeader | `PageHeader` | `title`, `sub`, `display` | 页面标题(actions 放 children) |
|
|
570
|
-
| Img | `Img` | `src`, `alt`, `fallback`, `loading`, `width`, `height` | 图片(含 fallback) |
|
|
571
|
-
| InView | `InView` | `once`, `threshold`, `rootMargin`, `placeholder`, `onEnter` | 进入视窗后懒加载内容 |
|
|
572
|
-
|
|
573
|
-
### 数据反馈
|
|
574
|
-
|
|
575
|
-
| 组件 | 导入名 | 关键 Props | 说明 |
|
|
576
|
-
|-----|--------|-----------|------|
|
|
577
|
-
| Modal | `Modal` | `open`, `title`, `onClose`, `width`, `footer`, `closable` | 模态框 |
|
|
578
|
-
| Confirm | `Confirm` | `open`, `message`, `confirmText`, `cancelText`, `variant`, `onConfirm`, `onCancel` | 确认对话框(同 `ctx.confirm()` 命令式) |
|
|
579
|
-
| Drawer | `Drawer` | `open`, `title`, `position: DrawerPosition`, `onClose`, `footer` | 抽屉 |
|
|
580
|
-
| Tooltip | `Tooltip` | `content`, `position: TooltipPosition`, `disabled` | 工具提示(hover/focus 触发) |
|
|
581
|
-
| Popover | `Popover` | `content`, `position: PopoverPosition`, `trigger`, `open`, `onOpenChange`, `disabled` | 弹出层 |
|
|
582
|
-
| Toast | `Toast` | `toasts: ToastItem[]`, `position`, `max`, `onRemove` | 消息提示 |
|
|
583
|
-
| Alert | `Alert` | `variant: AlertVariant`, `closable`, `onClose` | 警告提示(内容放 children) |
|
|
584
|
-
| Loading | `Loading` | `text` | 加载中 |
|
|
585
|
-
| EmptyState | `EmptyState` | `icon`, `text`, `hint` | 空状态(操作放 children) |
|
|
586
|
-
| Skeleton | `Skeleton` | `variant: SkeletonVariant`, `lines`, `cols`, `width`, `height` | 骨架屏 |
|
|
587
|
-
|
|
588
|
-
### 导航组件
|
|
589
|
-
|
|
590
|
-
| 组件 | 导入名 | 关键 Props | 说明 |
|
|
591
|
-
|-----|--------|-----------|------|
|
|
592
|
-
| Breadcrumb | `Breadcrumb` | `items: BreadcrumbItem[]` | 面包屑 |
|
|
593
|
-
| Menu | `Menu` | `items: MenuItem[]`, `activeKey`, `onSelect` | 侧栏导航(分组 + 图标 + 方向键) |
|
|
594
|
-
| Tabs | `Tabs` | `items: TabItem[]`, `active`, `onChange` | 标签页 |
|
|
595
|
-
| Dropdown | `Dropdown` | `trigger`, `items: DropdownItem[]`, `open`, `onOpenChange` | 下拉菜单 |
|
|
596
|
-
| Pagination | `Pagination` | `total`, `page`, `pageSize`, `onChange` | 分页 |
|
|
597
|
-
| Steps | `Steps` | `items: StepItem[]`(`{ key, label }`), `current`, `active` | 步骤条 |
|
|
598
|
-
| Accordion | `Accordion` | `items: AccordionItem[]`, `multiple` | 手风琴 |
|
|
599
|
-
|
|
600
|
-
### 新增批次(全量 92 组件)
|
|
601
|
-
|
|
602
|
-
| 组件 | 导入名 | 关键 Props | 说明 |
|
|
603
|
-
|-----|--------|-----------|------|
|
|
604
|
-
| Rate | `Rate` | `value`, `count`, `onChange`, `allowClear`, `readOnly`, `size` | 评分(键盘方向键/Home/End) |
|
|
605
|
-
| Typography | `Title` `Text` `Paragraph` | `Title: level 1-5`;`Text: type/strong/underline/strike/mark/code`;`Paragraph: ellipsis` | 语义排版(Title/Text/Paragraph 三组件) |
|
|
606
|
-
| Label | `Label` | `htmlFor`, `required` | 独立标签(必填星号) |
|
|
607
|
-
| AspectRatio | `AspectRatio` | `ratio` | 宽高比容器(内容填满) |
|
|
608
|
-
| Toggle | `Toggle` | `pressed`, `onPressedChange`, `variant`, `size` | 切换按钮(shadcn 对齐) |
|
|
609
|
-
| ToggleGroup | `ToggleGroup` | `type: 'single'\|'multiple'`, `options`, `value`, `onChange` | 切换组 |
|
|
610
|
-
| CheckboxGroup | `CheckboxGroup` | `options`, `value: string[]`, `onChange`, `cols` | 复选框组(栅格列数) |
|
|
611
|
-
| PinInput | `PinInput` | `length`, `value`, `onChange`, `type` | 验证码输入(自动聚焦/粘贴分派/回退) |
|
|
612
|
-
| CopyButton | `CopyButton` | `value`, `label`, `onCopy` | 复制按钮(clipboard + execCommand 降级) |
|
|
613
|
-
| ColorPicker | `ColorPicker` | `value`, `onChange`, `showInput`, `preset` | 颜色选择(预设色板 + hex 输入) |
|
|
614
|
-
| HoverCard | `HoverCard` | `content`, `position`, `openDelay`, `closeDelay` | 悬停富内容卡(shadcn) |
|
|
615
|
-
| Notification | `Notification` | 命令式 `notification.success/error/warning/open` | 队列式通知(antd 对齐) |
|
|
616
|
-
| BackTop | `BackTop` | `visibilityHeight`, `target`, `smooth` | 回到顶部(滚动超阈值显示) |
|
|
617
|
-
| Affix | `Affix` | `offsetTop`, `target` | 固定定位(滚动超阈值钉住) |
|
|
618
|
-
| ContextMenu | `ContextMenu` | `items: ContextMenuItem[]`(`{ label, onClick, variant: 'danger' }`) | 右键菜单(光标定位 + 方向键) |
|
|
619
|
-
| Mentions | `Mentions` | `options: { value, label }[]`, `value`, `onChange`, `prefix` | @提及(composition 抑制) |
|
|
620
|
-
| Collapse | `Collapse` | `items: CollapseItem[]`(`{ key, title, content, loading }`), `active`, `multiple` | 行内折叠(异步 loading) |
|
|
621
|
-
| Tree | `Tree` | `data: TreeNode[]`, `expandedKeys`, `checkedKeys`, `checkable`, `selectedKeys`, `onCheck/onExpand/onSelect` | 树(递归 + 勾选父子联动 + 半选传播;空数据「暂无数据」) |
|
|
622
|
-
| Cascader | `Cascader` | `options: CascaderOption[]`, `value: string[]`, `onChange` | 级联选择(多列推进) |
|
|
623
|
-
| Transfer | `Transfer` | `data: { key, label }[]`, `targetKeys`, `onChange`, `titles` | 穿梭框(选中 + 批量移动) |
|
|
624
|
-
| Command | `Command` | `items: CommandItem[]`, `open`, `onOpenChange`, `shortcut` | 命令面板(⌘K 全局 + 键盘流) |
|
|
625
|
-
| Menubar | `Menubar` | `menus: { key, label, items }[]` | 水平菜单栏(←→ 切换 + ↓ 展开) |
|
|
626
|
-
| Carousel | `Carousel` | `children`, `autoplay`, `interval`, `loop`, `showArrows/Dots` | 轮播(箭头/圆点/循环/自动播放) |
|
|
627
|
-
| Resizable | `Resizable` | `direction`, `defaultSize`, `min/maxSize` | 拖拽分割面板(pointer + 键盘方向键) |
|
|
628
|
-
| Calendar | `Calendar` | `month`, `year`, `events`, `selectedDate`, `onMonthChange/onSelectDate` | 月历(事件点 + 月切换 + 选日) |
|
|
629
|
-
| Watermark | `Watermark` | `text`, `fontSize`, `rotate`, `zIndex` | 水印(canvas 平铺) |
|
|
630
|
-
| VirtualList | `VirtualList` | `items`, `height`, `itemHeight`, `renderItem`, `overscan`, `emptyText` | 虚拟列表(spacer + 可见窗口,1000+ 条;空态占位) |
|
|
631
|
-
| InfiniteScroll | `InfiniteScroll` | `hasMore`, `loadMore`, `children`, `loader` | 触底加载(IntersectionObserver) |
|
|
632
|
-
| QRCode | `QRCode` | `value`, `ecLevel`, `size`, `color`, `bgColor` | 二维码(自研 Reed-Solomon,版本 1-6) |
|
|
633
|
-
|
|
634
|
-
### 图表
|
|
635
|
-
|
|
636
|
-
| 组件 | 导入名 | 关键 Props | 说明 |
|
|
637
|
-
|-----|--------|-----------|------|
|
|
638
|
-
| Chart | `Chart` | `type: ChartType`, `data`, `options`, `title`, `area` | SVG 图表(line/bar/pie)|
|
|
639
|
-
| DatePicker | `DatePicker` | `mode: DatePickerMode`, `value`, `onChange`, `placeholder`, `disabled` | 日期选择器(date/datetime/time/range)|
|
|
640
|
-
| Editor | `Editor` | `value`, `onChange`, `toolbar`, `placeholder`, `disabled`, `ai?` | 富文本编辑器(事件流事务层:撤销/重做/时光机;AI 协作可选) |
|
|
641
|
-
| FilePreview | `FilePreview` | `type`, `content?`, `url?`, `editable?`, `ai?`, `onSave?` | 文件预览(md/html/pdf/office/text)——基于事件流,md/text 可编辑 |
|
|
642
|
-
|
|
643
|
-
### Editor(富文本编辑器 + AI 协作)
|
|
644
|
-
|
|
645
|
-
基于 contentEditable 的富文本编辑器,**事件流事务层**:语义操作(格式/链接/图片/表格/AI 替换)→ `edit:commit`(before 快照 + 事件)→ 撤销/重做/时光机精确到任意版本。
|
|
646
|
-
|
|
647
|
-
```tsx
|
|
648
|
-
import { Editor } from 'weifuwu/components'
|
|
649
|
-
|
|
650
|
-
<Editor value={html} onChange={v => setHtml(v)} placeholder="输入内容..." />
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
**Props**:
|
|
654
|
-
|
|
655
|
-
| Prop | 类型 | 说明 |
|
|
656
|
-
|------|------|------|
|
|
657
|
-
| `value` / `onChange` | `string` / `(html) => void` | 受控 HTML(内部模型为准——输出经序列化归一化) |
|
|
658
|
-
| `toolbar` | `ToolbarItem[]` | 工具栏项(bold/italic/h1-3/align/link/image/table/clear/source…);默认 18 项 |
|
|
659
|
-
| `placeholder` / `disabled` / `minHeight` | | 占位符 / 禁用 / 最小高度 |
|
|
660
|
-
| `onUpload` | `(file) => Promise<string>` | 图片上传(返回 URL);不传则 URL 输入 |
|
|
661
|
-
| `ai` | `EditorAiOptions` | **AI 协作(可选)**——见下 |
|
|
662
|
-
| `draftKey` | `string` | **草稿持久化(可选)**:内容自动保存(防抖 500ms),挂载时 `value` 为空且存在草稿 → 自动恢复(刷新/崩溃不丢) |
|
|
663
|
-
|
|
664
|
-
**撤销/重做/时光机**:
|
|
665
|
-
|
|
666
|
-
- `Ctrl+Z` / `Ctrl+Y`:一步撤销/重做**语义操作**(输入合并为单步——连续打字一次撤销全退)
|
|
667
|
-
- 工具栏 🕘 **操作历史**:commit 列表(标签 + 时间)→ 点击回到任意版本(redo 保留可重做回来)
|
|
668
|
-
|
|
669
|
-
**AI 协作**(`ai` prop——不传则无 AI 能力):
|
|
670
|
-
|
|
671
|
-
```tsx
|
|
672
|
-
<Editor
|
|
673
|
-
value={html}
|
|
674
|
-
onChange={v => setHtml(v)}
|
|
675
|
-
ai={{ url: '/api/ai-editor' }} // wf: SSE 端点([ai-contract](../../docs/ai-contract.md))
|
|
676
|
-
/>
|
|
677
|
-
```
|
|
678
|
-
|
|
679
|
-
- 工具栏 AI 动作组(默认:润色/翻译/缩写/扩写/纠错)——选中文本(无选区 = 全文)→ 点击 → 浮层**流式**生成建议(原文 diff 对比)→ **接受**(替换 = 一个原子撤销步)/ **拒绝**
|
|
680
|
-
- `Ctrl+Enter`:快速触发最近使用的 AI 动作
|
|
681
|
-
- 自定义动作:`ai.actions`(prompt 模板注入 `{selection}`)
|
|
682
|
-
|
|
683
|
-
```tsx
|
|
684
|
-
<Editor value={html} onChange={v => setHtml(v)}
|
|
685
|
-
ai={{
|
|
686
|
-
url: '/api/ai-editor',
|
|
687
|
-
actions: [{
|
|
688
|
-
id: 'tone', label: '改语气',
|
|
689
|
-
prompt: ({ selection }) => `请把以下文本改为正式语气:\n\n${selection}`,
|
|
690
|
-
}],
|
|
691
|
-
}} />
|
|
692
|
-
```
|
|
693
|
-
|
|
694
|
-
### FilePreview(文件预览——基于事件流)
|
|
695
|
-
|
|
696
|
-
md/html/pdf/office/text 文件预览——**文档 = fold(事件流)**(复用 Editor 文档模型):
|
|
697
|
-
md/text 解析为 DocState——预览/编辑/撤销/AI 同一模型;编辑后可序列化回 md 保存。
|
|
698
|
-
|
|
699
|
-
```tsx
|
|
700
|
-
import { FilePreview } from 'weifuwu/components'
|
|
701
|
-
|
|
702
|
-
// md 预览 + 编辑 + AI 协作(润色文档 = 原子撤销)
|
|
703
|
-
<FilePreview type="md" content={md} editable ai={{ url: '/api/ai' }}
|
|
704
|
-
onSave={(md) => saveToSandbox(md)} fileName="README.md" />
|
|
705
|
-
```
|
|
706
|
-
|
|
707
|
-
**类型支持矩阵**:
|
|
708
|
-
|
|
709
|
-
| 类型 | 预览 | 编辑 | 说明 |
|
|
710
|
-
|------|------|------|------|
|
|
711
|
-
| `md` | ✅ 复用 `<Markdown>`(安全 token 渲染:表格/任务列表/URL 白名单) | ✅ 复用 `<Editor>`(事件流事务层——撤销/时光机/AI) | 编辑保存 = 序列化回 Markdown |
|
|
712
|
-
| `text` | `<pre>` | ✅ 复用 `<Editor>` | 纯文本 |
|
|
713
|
-
| `html` | ✅ iframe `sandbox`(安全隔离——不直插 DOM) | ❌(安全边界) | 只读 |
|
|
714
|
-
| `pdf` | ✅ iframe(浏览器原生查看器) | ❌ | 只读 |
|
|
715
|
-
| `office` | ✅ iframe(服务端转换产物 URL) | ❌ | 转换由服务端提供(前端零依赖——诚实裁剪) |
|
|
716
|
-
|
|
717
|
-
**Props**:`type`(可选——按 `fileName`/`url` 扩展名自动探测:md/txt/html/pdf/
|
|
718
|
-
docx 等)、`content`(md/html/text)、`url`(远程加载/文件服务路径)、
|
|
719
|
-
`editable`(md/text 切换 Editor)、`ai`(编辑模式透传 Editor AI 协作)、
|
|
720
|
-
`onSave(content, type)`(保存回写)、`onLoad`(解析完成)、`height`。
|
|
721
|
-
|
|
722
|
-
**交互**:工具条「复制」(原始内容——`ctx.browser.copyText`)+「保存」;
|
|
723
|
-
编辑模式 `Ctrl+S` 保存。远程文件(sandbox 路径):`url` 加载 + `onSave` 回写。
|
|
724
|
-
|
|
725
|
-
### SheetGrid(xlsx 网格编辑器——ODES 事件流)
|
|
726
|
-
|
|
727
|
-
**Props**:`workbook`(受控 WorkbookState——稀疏 cells Map)、`onChange`、
|
|
728
|
-
`ai`(AI 公式——SSE wf:)、`readonly`、`height`。
|
|
729
|
-
|
|
730
|
-
**能力**:单元格编辑(点击 → input → Enter/focusout 提交)、行列增删(引用平移)、
|
|
731
|
-
撤销(Ctrl+Z——commit 快照)、sheet 标签切换、**AI 公式**(选中单元格 → 相邻数据
|
|
732
|
-
上下文提示 → 浮层确认 → 接受 = cell-set commit 原子撤销)。
|
|
733
|
-
|
|
734
|
-
**事件流**:每个编辑 = `OfficeOp` → `__edit_tail(50, 'office')` 审计;AI 接受带
|
|
735
|
-
`target=messageId`(跨端关联 `__ai_events`)。
|
|
736
|
-
|
|
737
|
-
### SlideCanvas(pptx 画布编辑器——ODES 事件流)
|
|
738
|
-
|
|
739
|
-
**Props**:`deck`(受控 DeckState——slide → shape 几何集合)、`onChange`、
|
|
740
|
-
`ai`(AI 润色)、`readonly`、`height`。
|
|
741
|
-
|
|
742
|
-
**能力**:960×540 画布(scale 适配)、shape 拖拽移动/右下角缩放(pointerup 原子
|
|
743
|
-
提交)、双击文本编辑、幻灯片增删、Delete 删除、撤销、**AI 润色**(选中 shape →
|
|
744
|
-
浮层确认 → 接受 = shape-set commit)。
|
|
745
|
-
|
|
746
|
-
### Office 前端转换(零依赖——无需后端)
|
|
747
|
-
|
|
748
|
-
`weifuwu/office`(源码 `src/office/`——打包进 components):docx/xlsx/pptx ↔
|
|
749
|
-
ODES 模型(DocState/WorkbookState/DeckState)双向转换——自研 ZIP(EOCD→central→
|
|
750
|
-
local + `DecompressionStream('deflate-raw')`)+ 轻量 XML 解析器 + VNode 组件化
|
|
751
|
-
生成 OOXML(OOXML 也是 VNode——与前端 VNode → DOM 同构)。
|
|
752
|
-
|
|
753
|
-
**用法**(FilePreview 内置):`editable` office 类型 → 打开本地 docx/xlsx/pptx →
|
|
754
|
-
对应编辑器(Editor/SheetGrid/SlideCanvas)→ 下载导出。裁剪:复杂分节/公式计算/
|
|
755
|
-
动画母版——诚实提示。
|
|
756
|
-
|
|
757
|
-
**事件流**:预览加载 `editEmit('preview')`(`__edit_tail` 可审计);编辑走 Editor
|
|
758
|
-
commit 事件流(同一时间线)。**sandbox 集成**:`url` 加载 + `onSave` 回写由消费方接
|
|
759
|
-
文件读写工具。
|
|
760
|
-
|
|
761
|
-
**裁剪**:docx/xlsx/pptx 前端解析不做(零依赖——office 由服务端转换);代码块/
|
|
762
|
-
表格编辑时降级(超 Editor 模型——见 md 转换文档)。
|
|
763
|
-
|
|
764
|
-
### 布局
|
|
765
|
-
|
|
766
|
-
| 组件 | 导入名 | 关键 Props | 说明 |
|
|
767
|
-
|-----|--------|-----------|------|
|
|
768
|
-
| Divider | `Divider` | `vertical` | 分割线(水平带文字放 children,`vertical` 垂直) |
|
|
769
|
-
| AuthPage | `AuthPage` | `title`, `subtitle?`, `logo?`, `children`, `footer?`, `submitLabel`, `loading?`, `error?`, `onSubmit?` | 认证页骨架:居中卡片 + logo + 标题/副标题 + 表单插槽 + 错误条 + 提交 loading + 底部链接(登录/注册复用;认证流程/跳转由消费方提供) |
|
|
770
|
-
|
|
771
|
-
### AI 交互原语(wf: 协议配套)
|
|
772
|
-
|
|
773
|
-
| 组件 | 导入名 | 关键 Props | 说明 |
|
|
774
|
-
|-----|--------|-----------|------|
|
|
775
|
-
| AiChat | `AiChat` | `chat`, `maxHeight?`, `labels?`, `renderMessage?`, `renderToolArgs?` | 标准 AI 对话界面:气泡 + 工具卡 + 审批卡 + 自动滚动 + 错误重试(接收 `ctx.ui.useChat()` handle) |
|
|
776
|
-
| ChatInput | `ChatInput` | `value`, `onChange`, `onSend`, `streaming?`, `onStop?`, `error?`, `onRetry?`, `multiline?`, `actions?` | 独立聊天输入条(AiChat 抽取):单行/多行(Enter 发送/Shift+Enter 换行)+ streaming 停止切换 + §5.3 IME 受控输入纪律——纯输入层,聊天逻辑(useChat)由消费方组合 |
|
|
777
|
-
| MessageBubble | `MessageBubble` | `content`, `role`, `status`, `actions` | 独立消息气泡(业务聊天页复用) |
|
|
778
|
-
| ToolCallCard | `ToolCallCard` | `call`, `progress?`, `result?`, `renderArgs?` | 工具调用卡片:running(进度条)/ ok / error 三态(协议 §4) |
|
|
779
|
-
| JsonSchemaForm | `JsonSchemaForm` | `schema`, `value?`, `onChange?`, `onSubmit?`, `submitLabel?` | JSON Schema(对象子集)→ 参数输入表单:类型映射 + required/范围校验 + 嵌套/数组(工具参数输入面;不支持项告警降级) |
|
|
780
|
-
| ReasoningBlock | `ReasoningBlock` | `content`, `label?`, `defaultExpanded?`, `streaming?` | CoT 推理折叠展示(thinking 模式 `reasoning_content`;aria-expanded + 键盘可达 + 流式脉冲) |
|
|
781
|
-
| CitationCard | `CitationCard` | `items`, `label?`, `maxVisible?`, `defaultExpanded?`, `onOpen?` | RAG 引用来源展示:折叠「引用 N 条」+ 条目(序号/标题/来源/片段/链接)+ 溢出 +N;onOpen 时全部可点(调用方处理跳转) |
|
|
782
|
-
| SessionList | `SessionList` | `sessions`, `activeId?`, `onSelect?`, `onNew?`, `onRename?`, `onDelete?`, `searchable?` | 会话管理列表:分组(今天/昨天/更早)+ 选中高亮 + 搜索 + 行内重命名(Enter 确认/Escape 取消)/删除 + 键盘方向键导航 |
|
|
783
|
-
| ApprovalCard | `ApprovalCard` | `request`, `status?`, `onApprove(modifiedArgs?)`, `onReject`, `argsSchema?` | 人工审批卡片:待批(允许/拒绝+备注)/ 已批 / 已拒 / 超时;`argsSchema` 提供时渲染「修改参数」(JsonSchemaForm 预填 args,提交带修改后参数 → `onApprove(modifiedArgs)` → 父层选 modified 决策) |
|
|
784
|
-
|
|
785
|
-
### 全局工具
|
|
786
|
-
|
|
787
|
-
| 组件 | 导入名 | 关键 Props | 说明 |
|
|
788
|
-
|-----|--------|-----------|------|
|
|
789
|
-
| ThemeSwitch | `ThemeSwitch` | `mode: 'auto'\|'light'\|'dark'`, `onChange`, `storageKey` | 主题切换(auto/light/dark,localStorage 持久化);另有 `applyTheme()` / `getTheme()` 命令式工具 |
|
|
790
|
-
|
|
791
|
-
---
|
|
792
|
-
|
|
793
|
-
---
|
|
794
|
-
|
|
795
|
-
## 易混组件对照(选型必读——名字相近或功能重叠时的一句话决策)
|
|
796
|
-
|
|
797
|
-
| 易混组 | 选型规则(一句话) |
|
|
798
|
-
|--------|------------------|
|
|
799
|
-
| Toast vs Notification | 操作反馈(轻、自动消失) vs 系统通知(重、持久列表)——命令式 API 同源 |
|
|
800
|
-
| Menu vs Menubar vs NavMenu | 侧栏菜单(分组+方向键) vs 水平菜单栏(顶层+子菜单) vs 页面主导航(子菜单折叠态) |
|
|
801
|
-
| List vs VirtualList | 数据量 <500 用 List;>500 或未知用 VirtualList(固定行高) |
|
|
802
|
-
| Table vs VirtualTable | 同 List 规则(VirtualTable 虚拟行渲染) |
|
|
803
|
-
| Select vs AutoComplete vs SearchInput | 固定选项单选 vs 自由输入联想(带下拉) vs 搜索框(无下拉语义) |
|
|
804
|
-
| Editor vs CodeEditor vs MarkdownEditor | 轻量 markdown vs 代码(行号/Tab) vs 分屏实时预览 |
|
|
805
|
-
| Collapse vs Accordion | 多开(互不干扰) vs 单开(互斥语义) |
|
|
806
|
-
| Alert vs AlertGroup | 单条静态 vs 多条轮播(自动/手动切换) |
|
|
807
|
-
| ToggleGroup vs SegmentedControl | pressed 状态语义(shadcn) vs 选中态样式(antd Segmented) |
|
|
808
|
-
| Img vs ImageCropper vs Avatar | 展示+预览 vs 裁剪流程 vs 头像(名字哈希色) |
|
|
809
|
-
| Tree vs TreeSelect vs Cascader | 树形展示/勾选 vs 树形选择(下拉) vs 级联选择(路径语义) |
|
|
810
|
-
| SheetGrid vs SlideCanvas(FilePreview.Sheet/.Slide) | xlsx 网格编辑 vs pptx 画布编辑——均从 FilePreview 入口发现 |
|
|
811
|
-
|
|
812
|
-
> **家族导航**:`FilePreview`(预览入口)→ `FilePreview.Sheet`(xlsx)/ `FilePreview.Slide`(pptx);
|
|
813
|
-
> AI 会话族(AiChat/ChatInput/MessageBubble/SessionList/ReasoningBlock/ToolCallCard/CitationCard/ApprovalCard)统一归 ai 分类。
|