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,64 +0,0 @@
|
|
|
1
|
-
# 布局选型指南(什么时候用哪个原语)
|
|
2
|
-
|
|
3
|
-
> 解决"会用原语但不会选"——布局决策树:骨架/分区/间距/定位/响应式。
|
|
4
|
-
> 与 [页面组装](page-building.md) 配合:本页决定"用什么",组装决定"怎么搭"。
|
|
5
|
-
|
|
6
|
-
## 1. 能力光谱(选型总原则)
|
|
7
|
-
|
|
8
|
-
```
|
|
9
|
-
从组合层往下找——Table 能解决不自己拼:
|
|
10
|
-
组合层 Table / Form / Descriptions / StatCard (开箱即用——优先)
|
|
11
|
-
命名层 Grid / Space / Typography / Card (有 API 有语义)
|
|
12
|
-
裸原语 wf-grid / wf-gap-* / wf-text-* (自由但无约定——兜底)
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## 2. 决策树
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
页面骨架?
|
|
19
|
-
├─ 有侧栏+顶栏 → wf-app-shell(patterns/app-shell 蓝本)或 Layout 组件
|
|
20
|
-
├─ 独立定宽页 → wf-container(--wf-max 控制宽度)
|
|
21
|
-
└─ 全屏/无壳 → 直接 wf-stack / wf-fill
|
|
22
|
-
|
|
23
|
-
内容分区?
|
|
24
|
-
├─ 纵向堆叠 → wf-stack(页面默认)
|
|
25
|
-
├─ 横向排列 → wf-row(按钮组/表单行)
|
|
26
|
-
├─ 响应式网格 → wf-grid(--wf-cols: repeat(auto-fit, minmax(...)))
|
|
27
|
-
├─ 两栏固定比例 → wf-split(--wf-split-ratio)
|
|
28
|
-
└─ 居中专区 → wf-center(hero/空态/认证)
|
|
29
|
-
|
|
30
|
-
间距?
|
|
31
|
-
├─ 区域间 → wf-gap-lg / wf-gap-md(stack/row 的 --wf-gap)
|
|
32
|
-
├─ 元素内 → wf-p-*(卡片内边距)
|
|
33
|
-
└─ 标题留白 → wf-mb-*(仅 margin-bottom 用 m-,其余用 gap)
|
|
34
|
-
|
|
35
|
-
定位/层级?
|
|
36
|
-
├─ 吸顶 → wf-sticky(页面级)或 Affix 组件(滚动跟随)
|
|
37
|
-
├─ 悬浮按钮 → FloatButton 组件
|
|
38
|
-
├─ 角标覆盖 → wf-layer + wf-pop(容器内定位)
|
|
39
|
-
└─ 弹层 → 组件(openPopup 命令式——禁手写定位)
|
|
40
|
-
|
|
41
|
-
响应式?
|
|
42
|
-
├─ 隐藏/显示 → wf-hidden / wf-hidden@lg / wf-flex@lg
|
|
43
|
-
├─ 网格列数 → --wf-cols 的 auto-fit/auto-fill(窄屏自动收)
|
|
44
|
-
└─ 表格 → Table minWidth + 横向滚动
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## 3. 组件 vs 原语的边界(5 个重叠组件的分工)
|
|
48
|
-
|
|
49
|
-
| 场景 | 用原语 | 用组件 |
|
|
50
|
-
|------|--------|--------|
|
|
51
|
-
| 简单响应式网格 | wf-grid | Grid(24 栅格/列偏移——antd 迁移心智) |
|
|
52
|
-
| 简单间距 | wf-gap-* | Space(split 分隔符/方向控制) |
|
|
53
|
-
| 纯分隔线 | wf-border-t | Divider(带文字/vertical) |
|
|
54
|
-
| 简单字号 | wf-text-* | Typography(语义标签/mark/code) |
|
|
55
|
-
| 普通滚动容器 | wf-scroll | Scrollbar(自定义滚动条外观) |
|
|
56
|
-
|
|
57
|
-
## 4. 布局纪律(红线)
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
□ 布局结构只用 wf-* 原语(零手写 CSS)
|
|
61
|
-
□ 先查框架再动手(layout 原语 + 组件 + patterns——三层都查过再自研)
|
|
62
|
-
□ 间距走 token 阶梯(--wf-space-* 派生类——不用魔数)
|
|
63
|
-
□ 新功能先查 wf-* 是否已覆盖(如吸顶:页面级 wf-sticky / 嵌套容器 Affix)
|
|
64
|
-
```
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
# 布局原语使用指南
|
|
2
|
-
|
|
3
|
-
> 从 docs/layout.md 迁移(content/ 文档库——随 npm 包发布,与框架版本同步)。
|
|
4
|
-
> 本页为叙述性指南——组件/能力逐项参考见 content/ 各域目录。
|
|
5
|
-
|
|
6
|
-
# 布局系统(weifuwu/layout)
|
|
7
|
-
|
|
8
|
-
纯 CSS 66 个布局原语 + 157 个工具类 + 182 个主题 Token。不绑定任何 JS 框架。
|
|
9
|
-
|
|
10
|
-
> **学习路径与命名规范**:见 [`样式体系指南`](../../docs/style-guide.md)——统一语法 `wf-<域>-<名>`、三档学习(组件 → 10 核心原语 → 完整速查)、场景速查、变量定制。
|
|
11
|
-
|
|
12
|
-
> **全栈 weifuwu 项目**:`weifuwu/components/style.css` 已包含布局系统,一条 import 就够了,无需单独引用本页。
|
|
13
|
-
> 本页仅适用于**非 weifuwu 项目**或**只需 CSS 布局**的场景。
|
|
14
|
-
|
|
15
|
-
```html
|
|
16
|
-
<link rel="stylesheet" href="/node_modules/weifuwu/layout">
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
或在 weifuwu 服务端通过 `ctx.ui.css` 直接引用包名(`ctx.ui.css` 自动解析 exports map):
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
// 方案 A:组件 + 布局全部搞定(推荐)
|
|
23
|
-
app.get('/style.css', (req, ctx) => ctx.ui.css('weifuwu/components/style.css'))
|
|
24
|
-
|
|
25
|
-
// 方案 B:只用布局
|
|
26
|
-
app.get('/layout.css', (req, ctx) => ctx.ui.css('weifuwu/layout'))
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
也支持相对路径:`ctx.ui.css('./src/style.css')`。
|
|
30
|
-
|
|
31
|
-
## 66 个布局原语
|
|
32
|
-
|
|
33
|
-
| 类别 | 原语 | 效果 |
|
|
34
|
-
|------|------|------|
|
|
35
|
-
| **排列** | `wf-stack` `wf-stack@sm/md/lg` | 纵向 flex + gap(断点变体→横向) |
|
|
36
|
-
| | `wf-stack-reverse` `@sm/md/lg` | 纵向反向 |
|
|
37
|
-
| | `wf-row` `wf-row@sm/md/lg` | 横向 flex + wrap + gap |
|
|
38
|
-
| | `wf-row-reverse` `@sm/md/lg` | 横向反向 |
|
|
39
|
-
| | `wf-nowrap` | flex-wrap: nowrap |
|
|
40
|
-
| | `wf-cluster` | 换行居中簇 |
|
|
41
|
-
| **分布** | `wf-split` | justify-content: space-between |
|
|
42
|
-
| | `wf-center` | 双轴居中 |
|
|
43
|
-
| | `wf-right` | justify-content: flex-end |
|
|
44
|
-
| | `wf-around` | space-around |
|
|
45
|
-
| | `wf-evenly` | space-evenly |
|
|
46
|
-
| **对齐** | `wf-top` | align-items: flex-start |
|
|
47
|
-
| | `wf-bottom` | align-items: flex-end |
|
|
48
|
-
| | `wf-stretch` | align-items: stretch |
|
|
49
|
-
| | `wf-items-start/center/end/stretch` | 设 `--wf-align`(wf-row 消费——items 命名) |
|
|
50
|
-
| | `wf-self-start/center/end/stretch` | align-self(弹性子项单元素对齐) |
|
|
51
|
-
| **弹性** | `wf-fill` | flex: 1 + min-width: 0 |
|
|
52
|
-
| | `wf-flex-none` | flex: none(`wf-fixed` 为兼容别名——易与 position:fixed 混淆,推荐新名) |
|
|
53
|
-
| | `wf-auto` | flex: auto |
|
|
54
|
-
| | `wf-shrink` | min-width/height: 0 |
|
|
55
|
-
| **Z轴** | `wf-cover` | position: fixed + inset: 0 |
|
|
56
|
-
| | `wf-pin` | position: fixed(角标/浮层锚点,坐标由 inline 控制——相对视口) |
|
|
57
|
-
| | `wf-pop` | position: absolute(容器内角标:配合 `wf-layer`/`wf-anchor` 父级) |
|
|
58
|
-
| | `wf-anchor` | position: relative |
|
|
59
|
-
| | `wf-layer` | position: relative + z-index |
|
|
60
|
-
| | `wf-sticky` | position: sticky |
|
|
61
|
-
| | `wf-popup` | 浮层基类:宽度视口 clamp(`min(var(--wf-popup-max, 480px), calc(100vw - 32px))`) |
|
|
62
|
-
| **安全区** | `wf-safe-bottom` / `wf-safe-top` | iOS 刘海屏/Home 条:`padding: env(safe-area-inset-*)` |
|
|
63
|
-
| **容器** | `wf-surface` | 基础面(border-radius + shadow + bg) |
|
|
64
|
-
| | `wf-grid` | display: grid + --wf-cols |
|
|
65
|
-
| | `wf-container` | max-width + margin: auto |
|
|
66
|
-
| | `wf-scroll` | overflow: auto |
|
|
67
|
-
| | `wf-clip` | overflow: hidden |
|
|
68
|
-
| **显隐** | `wf-hidden` `wf-hidden@sm/md/lg` | display: none |
|
|
69
|
-
| | `wf-flex` `wf-flex@sm/md/lg` | display: flex(响应式显隐的 flex 容器恢复用——见「组合规则」) |
|
|
70
|
-
| | `wf-block` `wf-block@sm/md/lg` | display: block |
|
|
71
|
-
| | `wf-inline` | display: inline |
|
|
72
|
-
| | `wf-inline-block` | display: inline-block |
|
|
73
|
-
| | `wf-contents` | display: contents |
|
|
74
|
-
| | `wf-dim` | opacity 0.7(运行中/历史态淡化) |
|
|
75
|
-
| **间距** | `wf-p-*` / `wf-px-*` / `wf-py-*`(xs~2xl,另有 `wf-p-0`) | padding:全/水平/垂直,引用 `--wf-space-*` |
|
|
76
|
-
| | `wf-m-0` | margin: 0 |
|
|
77
|
-
| | `wf-mt-*` / `wf-mb-*` / `wf-my-*` / `wf-ml-*` / `wf-mr-*`(xs~2xl + none) | margin:top/bottom/垂直/左/右 |
|
|
78
|
-
| | `wf-pt-*` / `wf-pb-*`(xs~2xl) | padding:单侧顶/底(分隔条场景) |
|
|
79
|
-
| | `wf-mx-auto` / `wf-my-auto` / `wf-mt-auto` / `wf-mb-auto` / `wf-ml-auto` / `wf-mr-auto` | margin: auto 居中 / flex 列推底 |
|
|
80
|
-
| | `wf-gap-*`(xs~2xl) | 为 flex/grid 原语设置 `--wf-gap` |
|
|
81
|
-
| **尺寸** | `wf-w-full` / `wf-h-full` / `wf-w-auto` | 宽/高 100%、auto |
|
|
82
|
-
| | `wf-w-xs…xl` / `wf-w-max` / `wf-w-md-auto` | 固定宽阶(`--wf-space-*` 派生)/ max-content / md 起 auto |
|
|
83
|
-
| **边框** | `wf-border` / `wf-border-t/b/l/r` | 1px 边框(`--wf-border-width` + `--wf-color-border`) |
|
|
84
|
-
| **面工具** | `wf-bg-secondary/tertiary/brand/success/warning/error/info`(`wf-bg-primary` 为 brand 别名) | 语义背景色(`--wf-color-*-bg`) |
|
|
85
|
-
| | `wf-elevate` | 抬升阴影(`--wf-shadow-*`) |
|
|
86
|
-
| | `wf-panel-in` | 内凹面板(次级背景 + 内边距) |
|
|
87
|
-
| | `wf-pill` | 胶囊圆角(999px,状态徽章/标签/色块) |
|
|
88
|
-
| | `wf-rounded-sm` `wf-rounded` `wf-rounded-md` `wf-rounded-lg` | 圆角工具(`--wf-radius-*`) |
|
|
89
|
-
| **气泡** | `wf-bubble` / `wf-bubble--own` / `wf-bubble--ai` | 聊天气泡(pre-wrap + 折行内建) |
|
|
90
|
-
| **打印** | `wf-print-hidden` / `wf-print-block` | 导出 PDF 时隐藏工具区 / 恢复块级 |
|
|
91
|
-
| **行高** | `wf-leading-tight` `wf-leading-base` `wf-leading-relaxed` | line-height(`--wf-line-height-*`) |
|
|
92
|
-
| **指针** | `wf-pointer` / `wf-not-allowed` | cursor: pointer / not-allowed |
|
|
93
|
-
| **内容排版** | `wf-prose` | 富文本正文(文章/博客/文档,一个类包 h2/p/ul/blockquote/pre…) |
|
|
94
|
-
| **外壳** | `wf-app-shell` | 应用外壳:侧边栏 + 主区 grid(`--wf-sidebar-width`) |
|
|
95
|
-
| | `wf-sidebar` `wf-sidebar-header` `wf-sidebar-body` `wf-sidebar-footer` | 侧边栏:品牌区/导航区/底部用户区,sticky 全高 |
|
|
96
|
-
| | `wf-nav` `wf-nav-group` `wf-nav-item` `wf-nav-icon` | 导航:分组标题 + 链接项(`--active` 激活态);折叠态 `wf-nav--collapsed`(图标-only——**导航项需加 `title` 属性**提供悬停提示,CSS 无法自动补) |
|
|
97
|
-
| | `wf-main` | 主内容区(padding + min-width: 0;长文本设 `--wf-main-max: 900px` 限宽居中——文档站场景) |
|
|
98
|
-
| | `wf-text-*` 排版工具 | 见下文「排版工具」 |
|
|
99
|
-
|
|
100
|
-
### 组合规则(冲突防线)
|
|
101
|
-
|
|
102
|
-
原语分两类:**布局身份类**(display/position/flex-direction——stack/row/grid/nav/center/cover/pop…)
|
|
103
|
-
与**叠加工具类**(gap/对齐/显隐——叠加在身份类上)。规则:
|
|
104
|
-
|
|
105
|
-
1. **同一元素只带一个布局身份类**——两个身份类设置同一属性不同值时 import 顺序定胜负,
|
|
106
|
-
静默失效(事故例:`wf-nav wf-row` → nav 的 column 胜,横向失效;`wf-grid wf-stack` → stack 胜,网格失效)。
|
|
107
|
-
`style-audit` 静态扫描 class 组合,命中即红。
|
|
108
|
-
2. **对齐工具可叠加**:`wf-top/right/bottom/stretch/between/around/evenly` 专门用于覆盖
|
|
109
|
-
`wf-row` 等的默认对齐(后导入获胜,组合合法)。`wf-nowrap` 专门关 `wf-row` 的 wrap。
|
|
110
|
-
3. **`wf-center` 是 column 双轴居中**(不是 justify-center)——要“行内水平居中”用 `wf-cluster`,
|
|
111
|
-
不要 `wf-row wf-center`(center 的 column 方向会静默覆盖 row)。
|
|
112
|
-
4. **响应式显隐用 `wf-flex@bp` 恢复**:`wf-hidden wf-flex@lg` = 窄隐宽显(flex 容器)。
|
|
113
|
-
不可用 `wf-block@lg`——block 会覆盖 `wf-stack` 的 display:flex,gap/mt-auto 静默失效。
|
|
114
|
-
5. **容器内角标用 `wf-pop`**(父级 `wf-layer`/`wf-anchor`);`wf-pin` 是相对视口的 fixed,
|
|
115
|
-
嵌进带壳页面会覆盖壳。
|
|
116
|
-
|
|
117
|
-
完整冲突矩阵由 `node scripts/layout-inventory.mjs --json` 生成(属性指纹自动推导)。
|
|
118
|
-
|
|
119
|
-
### 排版工具(`wf-text-*`)
|
|
120
|
-
|
|
121
|
-
| 工具 | 效果 |
|
|
122
|
-
|------|------|
|
|
123
|
-
| `wf-text-left/center/right` | text-align |
|
|
124
|
-
| `wf-text-xs…5xl` | 字号(`--wf-font-size-*`) |
|
|
125
|
-
| `wf-text-secondary/tertiary/disabled/brand`(`wf-text-primary` 为 brand 别名) | 中性色阶 |
|
|
126
|
-
| `wf-nums` | tabular-nums(数值防宽度抖动) |
|
|
127
|
-
| `wf-text-success/warning/error/info` | 语义色文本(`--wf-color-*`) |
|
|
128
|
-
| `wf-text-medium/semibold/bold` | 字重 |
|
|
129
|
-
| `wf-tracking-normal/wide/wider` | letter-spacing |
|
|
130
|
-
| `wf-uppercase/lowercase/capitalize` | text-transform |
|
|
131
|
-
| `wf-pre-wrap` | white-space: pre-wrap + word-break(聊天气泡/代码) |
|
|
132
|
-
| `wf-break-word` | overflow-wrap + word-break |
|
|
133
|
-
| `wf-text-nowrap` | white-space: nowrap |
|
|
134
|
-
| `wf-truncate` | 单行省略(ellipsis) |
|
|
135
|
-
| `wf-line-clamp-2/3` | 多行截断 |
|
|
136
|
-
|
|
137
|
-
## 182 个主题 Token
|
|
138
|
-
|
|
139
|
-
**双层结构**:原始层(Primitive,色值只定义一次,品牌/暗色调校改这里)+ 语义层(Semantic,组件消费)。
|
|
140
|
-
|
|
141
|
-
```css
|
|
142
|
-
/* ── 原始层 — 品牌/中性色值 + 暗色值,主题定制改这一层 ── */
|
|
143
|
-
--wf-brand-seed / --wf-dark-brand-seed /* 品牌 seed:改一个值全站换肤,50/500/600/700 色阶 color-mix 派生 */
|
|
144
|
-
--wf-brand-500 / --wf-brand-600 / --wf-brand-50 /* 品牌色阶(seed 派生,可单独覆盖) */
|
|
145
|
-
--wf-slate-900…50 / --wf-white /* 中性阶 */
|
|
146
|
-
--wf-dark-* /* 暗色值(暗色模式经间接层引用,零硬编码) */
|
|
147
|
-
|
|
148
|
-
/* ── 语义层 — 组件消费,暗色/主题切换覆盖这里 ── */
|
|
149
|
-
/* 状态层 */
|
|
150
|
-
--wf-state-hover / --wf-state-pressed / --wf-state-selected /* 交互状态反馈(暗色自动映射) */
|
|
151
|
-
--wf-color-bg-elevated /* 浮层面板底色(暗色抬升一级) */
|
|
152
|
-
/* 品牌色 */
|
|
153
|
-
--wf-color-primary / --wf-color-primary-hover / --wf-color-primary-bg
|
|
154
|
-
|
|
155
|
-
/* 语义色 */
|
|
156
|
-
--wf-color-success / --wf-color-success-bg
|
|
157
|
-
--wf-color-warning / --wf-color-warning-bg
|
|
158
|
-
--wf-color-error / --wf-color-error-bg
|
|
159
|
-
--wf-color-info / --wf-color-info-bg
|
|
160
|
-
|
|
161
|
-
/* 语义文字色(P2):浅底可读 700 级,文字用 -text、填充用 500 级 */
|
|
162
|
-
--wf-color-primary-text / --wf-color-success-text / --wf-color-warning-text / --wf-color-error-text / --wf-color-info-text
|
|
163
|
-
--wf-color-on-brand /* 实心品牌/语义底上的文字与图标 */
|
|
164
|
-
--wf-overlay /* 浮层遮罩(Modal/Drawer),暗色自动加深 */
|
|
165
|
-
|
|
166
|
-
/* 文字色 */
|
|
167
|
-
--wf-color-text / --wf-color-text-secondary / --wf-color-text-tertiary / --wf-color-text-disabled
|
|
168
|
-
|
|
169
|
-
/* 背景色 */
|
|
170
|
-
--wf-color-bg / --wf-color-bg-secondary / --wf-color-bg-tertiary
|
|
171
|
-
|
|
172
|
-
/* 边框色 */
|
|
173
|
-
--wf-color-border / --wf-color-border-light / --wf-color-border-dark
|
|
174
|
-
|
|
175
|
-
/* 字体(--wf-font-sans 已含 CJK 回退:PingFang SC / Hiragino / 雅黑 / Noto Sans SC——
|
|
176
|
-
中文原生:西文最优字形 + 中文三平台一致;--wf-font-mono 同) */
|
|
177
|
-
--wf-font-sans / --wf-font-mono
|
|
178
|
-
|
|
179
|
-
/* 字号: xs sm base lg xl 2xl 3xl 4xl 5xl display */
|
|
180
|
-
--wf-font-size-*
|
|
181
|
-
|
|
182
|
-
/* 字重: normal medium semibold bold */
|
|
183
|
-
--wf-font-weight-*
|
|
184
|
-
|
|
185
|
-
/* 行高: tight normal relaxed */
|
|
186
|
-
--wf-line-height-*
|
|
187
|
-
|
|
188
|
-
/* 字距: normal wide wider */
|
|
189
|
-
--wf-letter-spacing-*
|
|
190
|
-
|
|
191
|
-
/* 间距: xs sm md lg xl 2xl */
|
|
192
|
-
--wf-space-*
|
|
193
|
-
|
|
194
|
-
/* 间隔: xs sm md lg xl 2xl */
|
|
195
|
-
--wf-gap-*
|
|
196
|
-
|
|
197
|
-
/* 圆角: sm md lg xl */
|
|
198
|
-
--wf-radius-*
|
|
199
|
-
|
|
200
|
-
/* 阴影: sm md lg */
|
|
201
|
-
--wf-shadow-*
|
|
202
|
-
|
|
203
|
-
/* 动效(P0):时长阶梯/缓动曲线/位移量,全站动效统一引用 */
|
|
204
|
-
--wf-dur-fast / --wf-dur-base / --wf-dur-slow
|
|
205
|
-
--wf-ease-out / --wf-ease-in / --wf-ease-snap
|
|
206
|
-
--wf-motion-sm / --wf-motion-md / --wf-motion-lg
|
|
207
|
-
|
|
208
|
-
/* 表头/分组标题(P5):CJK 感知,默认 none/0,英文可覆盖 */
|
|
209
|
-
--wf-heading-case / --wf-heading-tracking
|
|
210
|
-
|
|
211
|
-
/* 数字(P5):tabular-nums 防宽度抖动(wf-nums 工具类) */
|
|
212
|
-
--wf-nums
|
|
213
|
-
|
|
214
|
-
/* 其他 */
|
|
215
|
-
--wf-border-width / --wf-focus-ring
|
|
216
|
-
--wf-transition-duration / --wf-transition-timing
|
|
217
|
-
--wf-accent-color / --wf-caret-color
|
|
218
|
-
--wf-opacity-disabled / --wf-opacity-overlay
|
|
219
|
-
--wf-pop-z / --wf-cover-z
|
|
220
|
-
|
|
221
|
-
/* 应用外壳 */
|
|
222
|
-
--wf-sidebar-width
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### 暗色模式
|
|
226
|
-
|
|
227
|
-
两种激活方式(显式 `data-theme` 优先级更高):
|
|
228
|
-
|
|
229
|
-
```ts
|
|
230
|
-
// 1. 手动切换
|
|
231
|
-
// document.documentElement.setAttribute('data-theme', 'dark')
|
|
232
|
-
// document.documentElement.setAttribute('data-theme', 'light') // 强制亮色
|
|
233
|
-
|
|
234
|
-
// 2. 自动:系统暗色偏好(无需任何代码)
|
|
235
|
-
// 系统为暗色时自动生效;加 data-theme="light" 可强制亮色
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
暗色值定义在原始层 `--wf-dark-*`(只写一次),`_dark.css` 两段仅做语义映射——改暗色调校只动原始层,无硬编码色值。
|
|
239
|
-
|
|
240
|
-
---
|
|
241
|
-
|