x-next 1.12.0 → 1.14.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/AI_CODING.md +6 -5
- package/AI_USAGE/catalog.md +106 -105
- package/AI_USAGE/components/alert-api.md +48 -0
- package/AI_USAGE/components/alert.md +222 -3
- package/AI_USAGE/components/bar-chart-api.md +177 -0
- package/AI_USAGE/components/bar-chart.md +297 -3
- package/AI_USAGE/components/boxicons.md +147 -0
- package/AI_USAGE/components/button-api.md +144 -0
- package/AI_USAGE/components/button.md +447 -3
- package/AI_USAGE/components/charts.md +81 -0
- package/AI_USAGE/components/checkbox-api.md +145 -0
- package/AI_USAGE/components/checkbox.md +365 -3
- package/AI_USAGE/components/color-picker-api.md +52 -0
- package/AI_USAGE/components/color-picker.md +211 -3
- package/AI_USAGE/components/config-provider-api.md +38 -0
- package/AI_USAGE/components/config-provider.md +250 -3
- package/AI_USAGE/components/date-picker-api.md +1114 -0
- package/AI_USAGE/components/date-picker.md +378 -3
- package/AI_USAGE/components/dialog-api.md +142 -0
- package/AI_USAGE/components/dialog.md +284 -3
- package/AI_USAGE/components/draggable-api.md +146 -0
- package/AI_USAGE/components/draggable.md +259 -0
- package/AI_USAGE/components/drawer-api.md +78 -0
- package/AI_USAGE/components/drawer.md +227 -0
- package/AI_USAGE/components/dropdown-api.md +529 -0
- package/AI_USAGE/components/dropdown.md +392 -3
- package/AI_USAGE/components/empty-api.md +36 -0
- package/AI_USAGE/components/empty.md +227 -3
- package/AI_USAGE/components/finicon.md +88 -0
- package/AI_USAGE/components/form-api.md +524 -0
- package/AI_USAGE/components/form.md +454 -0
- package/AI_USAGE/components/grid-api.md +527 -0
- package/AI_USAGE/components/grid.md +224 -0
- package/AI_USAGE/components/heatmap-api.md +122 -0
- package/AI_USAGE/components/heatmap.md +220 -0
- package/AI_USAGE/components/icon-api.md +4707 -0
- package/AI_USAGE/components/icon.md +257 -0
- package/AI_USAGE/components/image-api.md +440 -0
- package/AI_USAGE/components/image.md +465 -0
- package/AI_USAGE/components/input-api.md +184 -0
- package/AI_USAGE/components/input-number-api.md +66 -0
- package/AI_USAGE/components/input-number.md +294 -0
- package/AI_USAGE/components/input-tag-api.md +114 -0
- package/AI_USAGE/components/input-tag.md +482 -0
- package/AI_USAGE/components/input.md +293 -3
- package/AI_USAGE/components/layout-api.md +147 -0
- package/AI_USAGE/components/layout.md +230 -0
- package/AI_USAGE/components/line-chart-api.md +197 -0
- package/AI_USAGE/components/line-chart.md +279 -3
- package/AI_USAGE/components/link-api.md +42 -0
- package/AI_USAGE/components/link.md +197 -0
- package/AI_USAGE/components/menu-api.md +516 -0
- package/AI_USAGE/components/menu.md +268 -0
- package/AI_USAGE/components/message-api.md +215 -0
- package/AI_USAGE/components/message-box-api.md +108 -0
- package/AI_USAGE/components/message-box.md +268 -3
- package/AI_USAGE/components/message.md +231 -3
- package/AI_USAGE/components/network-api.md +91 -0
- package/AI_USAGE/components/network.md +378 -0
- package/AI_USAGE/components/notification-api.md +236 -0
- package/AI_USAGE/components/notification.md +275 -3
- package/AI_USAGE/components/pagination-api.md +62 -0
- package/AI_USAGE/components/pagination.md +386 -5
- package/AI_USAGE/components/pie-chart-api.md +109 -0
- package/AI_USAGE/components/pie-chart.md +245 -3
- package/AI_USAGE/components/popconfirm-api.md +75 -0
- package/AI_USAGE/components/popconfirm.md +231 -3
- package/AI_USAGE/components/popover-api.md +75 -0
- package/AI_USAGE/components/popover.md +208 -3
- package/AI_USAGE/components/popup-api.md +75 -0
- package/AI_USAGE/components/popup.md +52 -0
- package/AI_USAGE/components/progress-api.md +44 -0
- package/AI_USAGE/components/progress.md +248 -3
- package/AI_USAGE/components/radio-api.md +165 -0
- package/AI_USAGE/components/radio.md +259 -3
- package/AI_USAGE/components/rate-api.md +54 -0
- package/AI_USAGE/components/rate.md +233 -3
- package/AI_USAGE/components/resize-box-api.md +56 -0
- package/AI_USAGE/components/resize-box.md +231 -0
- package/AI_USAGE/components/scrollbar-api.md +77 -0
- package/AI_USAGE/components/scrollbar.md +218 -0
- package/AI_USAGE/components/select-api.md +758 -0
- package/AI_USAGE/components/select.md +640 -3
- package/AI_USAGE/components/skeleton-api.md +85 -0
- package/AI_USAGE/components/skeleton.md +150 -0
- package/AI_USAGE/components/slider-api.md +51 -0
- package/AI_USAGE/components/slider.md +233 -3
- package/AI_USAGE/components/space-api.md +38 -0
- package/AI_USAGE/components/space.md +145 -0
- package/AI_USAGE/components/spin-api.md +43 -0
- package/AI_USAGE/components/spin.md +205 -0
- package/AI_USAGE/components/steps-api.md +111 -0
- package/AI_USAGE/components/steps.md +201 -3
- package/AI_USAGE/components/switch-api.md +58 -0
- package/AI_USAGE/components/switch.md +290 -3
- package/AI_USAGE/components/table-api.md +2919 -0
- package/AI_USAGE/components/table.md +1414 -0
- package/AI_USAGE/components/tabs-api.md +135 -0
- package/AI_USAGE/components/tabs.md +308 -3
- package/AI_USAGE/components/tag-api.md +124 -0
- package/AI_USAGE/components/tag.md +292 -0
- package/AI_USAGE/components/textarea-api.md +55 -0
- package/AI_USAGE/components/textarea.md +326 -3
- package/AI_USAGE/components/time-picker-api.md +137 -0
- package/AI_USAGE/components/time-picker.md +271 -3
- package/AI_USAGE/components/time-range-selector-api.md +44 -0
- package/AI_USAGE/components/time-range-selector.md +355 -0
- package/AI_USAGE/components/timeline-api.md +93 -0
- package/AI_USAGE/components/timeline.md +312 -0
- package/AI_USAGE/components/tooltip-api.md +77 -0
- package/AI_USAGE/components/tooltip.md +182 -0
- package/AI_USAGE/components/trend-chart-api.md +119 -0
- package/AI_USAGE/components/trend-chart.md +335 -0
- package/AI_USAGE/components/trigger-api.md +124 -0
- package/AI_USAGE/components/trigger.md +185 -0
- package/AI_USAGE/components/upload-api.md +200 -0
- package/AI_USAGE/components/upload.md +711 -3
- package/AI_USAGE/components/watermark-api.md +87 -0
- package/AI_USAGE/components/watermark.md +200 -0
- package/AI_USAGE/core.md +1 -1
- package/AI_USAGE/index.md +35 -7
- package/AI_USAGE/recipes/form-on-demand.md +1 -1
- package/AI_USAGE.md +33657 -7
- package/CHANGELOG.md +40 -0
- package/dist/_utils/inherit-component-type.d.ts +11 -0
- package/dist/components/date-picker/index.d.ts +420 -5
- package/dist/components/form-input/index.d.ts +617 -2
- package/dist/components/layout/index.d.ts +689 -1
- package/dist/components/menu/index.d.ts +786 -1
- package/dist/components/network/Network.vue.d.ts +7 -3
- package/dist/components/network/index.d.ts +10 -2
- package/dist/components/network/props.d.ts +5 -0
- package/dist/components/network/utils.d.ts +3 -3
- package/dist/components/pagination/page-item-ellipsis.vue.d.ts +4 -1
- package/dist/components/pagination/page-item-step.vue.d.ts +101 -130
- package/dist/components/pagination/page-item.vue.d.ts +1 -0
- package/dist/components/pagination/page-jumper.vue.d.ts +1 -1
- package/dist/components/pagination/page-options.vue.d.ts +6 -4
- package/dist/components/pagination/utils.d.ts +3 -0
- package/dist/components/time-range-selector/index.d.ts +6 -6
- package/dist/es/_container/resize-observer-v2.js +1 -1
- package/dist/es/_container/resize-observer.js +1 -1
- package/dist/es/_hooks/use-resize-observer.js +1 -1
- package/dist/es/_styles/palette-aliases.js +4 -4
- package/dist/es/_utils/inherit-component-type.js +6 -0
- package/dist/es/_virtual/advancedFormat.js +1 -1
- package/dist/es/_virtual/customParseFormat.js +1 -1
- package/dist/es/_virtual/dayjs.min.js +1 -1
- package/dist/es/_virtual/isBetween.js +1 -1
- package/dist/es/_virtual/quarterOfYear.js +1 -1
- package/dist/es/_virtual/weekOfYear.js +1 -1
- package/dist/es/_virtual/weekYear.js +1 -1
- package/dist/es/_virtual/zh-cn.js +1 -1
- package/dist/es/components/button/Button.js +53 -42
- package/dist/es/components/date-picker/index.js +18 -17
- package/dist/es/components/draggable/useDraggable.js +1 -1
- package/dist/es/components/form/Form.vue2.js +1 -1
- package/dist/es/components/form/FormItem.vue2.js +1 -1
- package/dist/es/components/form-input/index.js +12 -11
- package/dist/es/components/form-input-number/InputNumber.js +1 -1
- package/dist/es/components/form-slider/Slider.vue2.js +1 -1
- package/dist/es/components/form-slider/slider-ticks.vue2.js +1 -1
- package/dist/es/components/form-slider/utils.js +1 -1
- package/dist/es/components/layout/index.js +10 -9
- package/dist/es/components/menu/MenuItem.js +1 -1
- package/dist/es/components/menu/hooks/use-level.js +5 -5
- package/dist/es/components/menu/index.js +13 -10
- package/dist/es/components/menu/overflow-wrap.js +1 -1
- package/dist/es/components/network/Network.vue.js +17 -12
- package/dist/es/components/network/Network.vue2.js +78 -70
- package/dist/es/components/network/utils.js +112 -71
- package/dist/es/components/pagination/Pagination.js +132 -123
- package/dist/es/components/pagination/page-item-ellipsis.vue.js +10 -10
- package/dist/es/components/pagination/page-item-ellipsis.vue2.js +24 -19
- package/dist/es/components/pagination/page-item-step.vue.js +14 -11
- package/dist/es/components/pagination/page-item-step.vue2.js +20 -22
- package/dist/es/components/pagination/page-item.vue.js +10 -9
- package/dist/es/components/pagination/page-item.vue2.js +24 -19
- package/dist/es/components/pagination/page-jumper.vue2.js +23 -23
- package/dist/es/components/pagination/page-options.vue.js +15 -10
- package/dist/es/components/pagination/page-options.vue2.js +21 -17
- package/dist/es/components/pagination/utils.js +4 -2
- package/dist/es/components/progress/circle.vue2.js +1 -1
- package/dist/es/components/progress/line.vue2.js +1 -1
- package/dist/es/components/progress/steps.vue2.js +1 -1
- package/dist/es/components/rate/Rate.js +1 -1
- package/dist/es/components/virtual-list-v2/virtual-list-item.js +1 -1
- package/dist/es/locale/en-US.js +2 -0
- package/dist/es/locale/zh-CN.js +2 -0
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/dayjs.min.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/locale/zh-cn.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/advancedFormat.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/customParseFormat.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/isBetween.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/quarterOfYear.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/weekOfYear.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/weekYear.js +1 -1
- package/dist/es/style.css +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/locale/interface.d.ts +3 -0
- package/dist/style/base.css +1 -1
- package/dist/style/button.css +1 -1
- package/dist/style/form-select.css +1 -1
- package/dist/style/network.css +1 -1
- package/dist/style/pagination.css +1 -1
- package/dist/style/table.css +1 -1
- package/dist/style.css +1 -1
- package/package.json +10 -5
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/index.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/is.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/locale/en-US.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/array.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/base.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/boolean.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/custom.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/number.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/object.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/string.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/type.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/util.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/compute-scroll-into-view@3.1.1/node_modules/compute-scroll-into-view/dist/index.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/number-precision@1.6.0/node_modules/number-precision/build/index.es.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/scroll-into-view-if-needed@3.1.0/node_modules/scroll-into-view-if-needed/dist/index.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/sortablejs@1.15.7/node_modules/sortablejs/modular/sortable.esm.js +0 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
|
+
# TrendChart AI 使用
|
|
3
|
+
|
|
4
|
+
适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
|
|
5
|
+
|
|
6
|
+
先读 [通用接入](../core.md)。公开导出:`TrendChart`;主要模型:无。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./trend-chart-api.md),包含本组件族全部子组件和别名。
|
|
7
|
+
|
|
8
|
+
按需样式:`x-next/style/base.css`(包含 base.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
|
|
9
|
+
|
|
10
|
+
## 场景用法
|
|
11
|
+
|
|
12
|
+
以下示例从本地 `src/docs/components/trend-chart.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./trend-chart-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
|
|
13
|
+
|
|
14
|
+
### 用途与选型
|
|
15
|
+
|
|
16
|
+
用于展示小型趋势、指标变化和概览图表。组件默认渲染为 100% 宽 × 60px 高的迷你图,适合放在仪表盘卡片、表格单元格和指标标签中。
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### 与其它图表的分工
|
|
20
|
+
|
|
21
|
+
TrendChart 是**迷你图**:无坐标轴、无图例、单条曲线,用于卡片角落的形态提示。需要坐标轴读数或多系列对比时用 [LineChart 折线图](./line-chart.md);完整的选择指引见[图表总览](./charts.md)。
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### 基础用法
|
|
25
|
+
|
|
26
|
+
不设置 `height` 时组件使用 60px 默认高度,无需外部容器样式。
|
|
27
|
+
|
|
28
|
+
```vue
|
|
29
|
+
<script setup lang="ts">
|
|
30
|
+
import 'x-next/style.css';
|
|
31
|
+
import { TrendChart } from 'x-next';
|
|
32
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
33
|
+
</script>
|
|
34
|
+
<template>
|
|
35
|
+
<TrendChart :dataset="dataset" status="success" />
|
|
36
|
+
</template>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 尺寸与权重
|
|
40
|
+
|
|
41
|
+
迷你图的推荐高度是 **40 ~ 60px**。高度超过 80px 后曲线会显得空旷,观感更接近「一条没有坐标轴的大图」而不是角标趋势;这种场景应该改用 [LineChart 折线图](./line-chart.md)。
|
|
42
|
+
|
|
43
|
+
`height` 与 `width` 接受数字(按 px 处理)或 CSS 值。数字宽度下组件不再撑满父容器,适合固定尺寸的卡片角标。
|
|
44
|
+
|
|
45
|
+
```vue
|
|
46
|
+
<script setup lang="ts">
|
|
47
|
+
import 'x-next/style.css';
|
|
48
|
+
import { TrendChart } from 'x-next';
|
|
49
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
50
|
+
</script>
|
|
51
|
+
<template>
|
|
52
|
+
<TrendChart :dataset="dataset" :height="40" />
|
|
53
|
+
<TrendChart :dataset="dataset" :height="60" />
|
|
54
|
+
<TrendChart :dataset="dataset" :height="80" />
|
|
55
|
+
</template>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 卡片场景
|
|
59
|
+
|
|
60
|
+
迷你图的实际用法是在指标卡里当角标:卡片给数值,图表给形态。下面的例子把宽度收到 120px 左右,与数值并排。
|
|
61
|
+
|
|
62
|
+
```vue
|
|
63
|
+
<script setup lang="ts">
|
|
64
|
+
import 'x-next/style.css';
|
|
65
|
+
import { TrendChart } from 'x-next';
|
|
66
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
67
|
+
</script>
|
|
68
|
+
<template>
|
|
69
|
+
<div class="metric-card">
|
|
70
|
+
<div>
|
|
71
|
+
<div class="metric-card-label">今日请求量</div>
|
|
72
|
+
<div class="metric-card-value">12,480</div>
|
|
73
|
+
</div>
|
|
74
|
+
<TrendChart :dataset="dataset" status="success" :height="40" :width="120" />
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
|
77
|
+
<style scoped>
|
|
78
|
+
.metric-card {
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: space-between;
|
|
82
|
+
gap: 16px;
|
|
83
|
+
width: 280px;
|
|
84
|
+
max-width: 100%;
|
|
85
|
+
padding: 12px 16px;
|
|
86
|
+
border: 1px solid var(--x-color-border-subtle);
|
|
87
|
+
border-radius: 8px;
|
|
88
|
+
}
|
|
89
|
+
.metric-card-value {
|
|
90
|
+
font-size: 20px;
|
|
91
|
+
font-weight: 500;
|
|
92
|
+
}
|
|
93
|
+
.metric-card-label {
|
|
94
|
+
color: var(--x-color-text-3);
|
|
95
|
+
font-size: 12px;
|
|
96
|
+
}
|
|
97
|
+
</style>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 状态主题
|
|
101
|
+
|
|
102
|
+
不传 `status` 时使用主色;`info` 为中性次要指标语义,适合同一卡片里弱化的对比项。
|
|
103
|
+
|
|
104
|
+
```vue
|
|
105
|
+
<script setup lang="ts">
|
|
106
|
+
import 'x-next/style.css';
|
|
107
|
+
import { TrendChart } from 'x-next';
|
|
108
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
109
|
+
</script>
|
|
110
|
+
<template>
|
|
111
|
+
<TrendChart :dataset="dataset" status="primary" :height="56" />
|
|
112
|
+
<TrendChart :dataset="dataset" status="warning" :height="56" />
|
|
113
|
+
<TrendChart :dataset="dataset" status="danger" :height="56" />
|
|
114
|
+
</template>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 曲线与填充
|
|
118
|
+
|
|
119
|
+
填充默认使用由描边色到透明的渐变;需要纯色块时通过 `theme.fill.type="solid"` 切换。
|
|
120
|
+
|
|
121
|
+
```vue
|
|
122
|
+
<script setup lang="ts">
|
|
123
|
+
import 'x-next/style.css';
|
|
124
|
+
import { TrendChart } from 'x-next';
|
|
125
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
126
|
+
</script>
|
|
127
|
+
<template>
|
|
128
|
+
<TrendChart :dataset="dataset" :smooth="false" :height="56" />
|
|
129
|
+
<TrendChart :dataset="dataset" :fill="false" :height="56" />
|
|
130
|
+
<TrendChart :dataset="dataset" :stroke="false" :height="56" />
|
|
131
|
+
</template>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 数据点显示
|
|
135
|
+
|
|
136
|
+
`show-points` 为 `auto`(默认)时,相邻点横向间距小于 18px 就自动隐藏普通点,避免小尺寸下点挤成一团;`true` 强制常显(点数多且空间窄时会显得拥挤,如上方第二例),`false` 完全隐藏。hover 时激活点始终可见。
|
|
137
|
+
|
|
138
|
+
```vue
|
|
139
|
+
<script setup lang="ts">
|
|
140
|
+
import 'x-next/style.css';
|
|
141
|
+
import { TrendChart } from 'x-next';
|
|
142
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
143
|
+
const denseDataset = [
|
|
144
|
+
12, 18, 14, 24, 32, 28, 36, 42, 30, 22, 26, 34,
|
|
145
|
+
18, 26, 22, 30, 38, 34, 40, 46, 36, 28, 32, 44,
|
|
146
|
+
];
|
|
147
|
+
/* 延迟趋势:整体平稳、尾部抬头,用于卡片示例 */
|
|
148
|
+
const latencyDataset = [196, 205, 188, 214, 202, 221, 208, 236];
|
|
149
|
+
</script>
|
|
150
|
+
<template>
|
|
151
|
+
<!-- 默认 auto:点距不足时自动隐藏普通点;show-points 强制常显 -->
|
|
152
|
+
<div class="chart-320">
|
|
153
|
+
<TrendChart :dataset="denseDataset" :height="80" />
|
|
154
|
+
</div>
|
|
155
|
+
<div class="chart-320">
|
|
156
|
+
<TrendChart :dataset="denseDataset" show-points :height="80" />
|
|
157
|
+
</div>
|
|
158
|
+
<div class="chart-320">
|
|
159
|
+
<TrendChart :dataset="dataset" :show-points="false" :height="80" />
|
|
160
|
+
</div>
|
|
161
|
+
</template>
|
|
162
|
+
<style scoped>
|
|
163
|
+
.chart-320 {
|
|
164
|
+
width: 320px;
|
|
165
|
+
max-width: 100%;
|
|
166
|
+
}
|
|
167
|
+
</style>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 纯形态,不带坐标轴
|
|
171
|
+
|
|
172
|
+
TrendChart 的 `grid` 与 `labels` 已**废弃**(1.8.0 起不渲染任何内容,props 声明保留到 2.0.0 移除)。这是有意的:**带网格和坐标文字的图属于 [LineChart 折线图](./line-chart.md)**,那里有类目轴、数值轴、多系列、图例和悬浮读数。
|
|
173
|
+
|
|
174
|
+
迷你图的职责只有一个——让用户一眼看出「在涨还是在跌、有没有异常尖峰」。加上坐标轴后,40~60px 的高度里曲线会被压扁,而标签又读不清,反而不如直接用折线图。
|
|
175
|
+
|
|
176
|
+
需要读数时:用 LineChart;想在这个尺寸下看具体数值,开 `tooltip` 悬浮即可(提示气泡会贴边收敛,不会被裁)。
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
### 交互事件
|
|
180
|
+
|
|
181
|
+
`tooltip` 开启后 hover 会在激活点旁显示 `tooltipFormatter` 的返回值,无需业务自己画提示层;激活竖线只从当前数据点连到绘图区底部,不会穿过整张图表;`mouse-move` 在数据变化导致激活点越界时会补发 `null`,业务侧不用额外兜底。
|
|
182
|
+
|
|
183
|
+
```vue
|
|
184
|
+
<script setup lang="ts">
|
|
185
|
+
import 'x-next/style.css';
|
|
186
|
+
import { TrendChart } from 'x-next';
|
|
187
|
+
import { ref } from 'vue';
|
|
188
|
+
|
|
189
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
190
|
+
const hoverInfo = ref('等待鼠标移动');
|
|
191
|
+
// tooltip 文本格式化函数放在 script 中,避免模板内联类型注解
|
|
192
|
+
const formatVolume = (value: number) => `${value} 单`;
|
|
193
|
+
const handleMouseMove = (event: { index: number; data: number } | null) => {
|
|
194
|
+
hoverInfo.value = event ? `index: ${event.index}, value: ${event.data}` : '已离开';
|
|
195
|
+
};
|
|
196
|
+
</script>
|
|
197
|
+
<template>
|
|
198
|
+
<TrendChart
|
|
199
|
+
:dataset="dataset"
|
|
200
|
+
interactive
|
|
201
|
+
tooltip
|
|
202
|
+
:height="120"
|
|
203
|
+
:tooltip-formatter="formatVolume"
|
|
204
|
+
@mouse-move="handleMouseMove"
|
|
205
|
+
/>
|
|
206
|
+
<p>{{ hoverInfo }}</p>
|
|
207
|
+
</template>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 数值区间
|
|
211
|
+
|
|
212
|
+
`min` / `max` 传入后即锁定可见区间,超出范围的数据会被裁剪在绘图区之外。适合「只看某个区间」或让同一组卡片统一 Y 轴口径。
|
|
213
|
+
|
|
214
|
+
```vue
|
|
215
|
+
<script setup lang="ts">
|
|
216
|
+
import 'x-next/style.css';
|
|
217
|
+
import { TrendChart } from 'x-next';
|
|
218
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
219
|
+
</script>
|
|
220
|
+
<template>
|
|
221
|
+
<TrendChart :dataset="dataset" :min="20" :max="40" interactive tooltip />
|
|
222
|
+
</template>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 自定义主题
|
|
226
|
+
|
|
227
|
+
主题会与状态主题按层级合并:只写 `color` 即可统一换色,单独设置 `stroke.color` 等字段可覆盖单层。
|
|
228
|
+
|
|
229
|
+
```vue
|
|
230
|
+
<script setup lang="ts">
|
|
231
|
+
import 'x-next/style.css';
|
|
232
|
+
import { TrendChart } from 'x-next';
|
|
233
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
234
|
+
|
|
235
|
+
const customTheme = {
|
|
236
|
+
// 统一基础色:未单独指定颜色的层级都会继承
|
|
237
|
+
color: '#7c3aed' as const,
|
|
238
|
+
// 默认权重:描边 1.5px、点半径 2px、激活竖线 1px
|
|
239
|
+
stroke: { width: 2 },
|
|
240
|
+
fill: { type: 'gradient' as const, opacity: 0.16 },
|
|
241
|
+
// point.width 实际为半径
|
|
242
|
+
point: { width: 3 },
|
|
243
|
+
axisLine: { width: 1, opacity: 0.7 },
|
|
244
|
+
};
|
|
245
|
+
</script>
|
|
246
|
+
<template>
|
|
247
|
+
<TrendChart :dataset="dataset" :theme="customTheme" />
|
|
248
|
+
</template>
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### 边界数据
|
|
252
|
+
|
|
253
|
+
```vue
|
|
254
|
+
<script setup lang="ts">
|
|
255
|
+
import 'x-next/style.css';
|
|
256
|
+
import { TrendChart } from 'x-next';
|
|
257
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
258
|
+
</script>
|
|
259
|
+
<template>
|
|
260
|
+
<TrendChart :dataset="[10, 10, 10, 10, 10]" :height="56" />
|
|
261
|
+
<TrendChart :dataset="[16]" :height="56" />
|
|
262
|
+
<TrendChart :dataset="[]" :height="56" />
|
|
263
|
+
</template>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 响应式尺寸
|
|
267
|
+
|
|
268
|
+
容器尺寸变化(侧边栏折叠、ResizeBox 拖动、Tab 切换)会由 `ResizeObserver` 自动触发重算,图表的点位和标签不会错位。拖动下面的右边缘或底边缘查看效果。
|
|
269
|
+
|
|
270
|
+
`height` 传 `'100%'` 时图表跟随父容器高度;容器尺寸变化无需监听 `window.resize`。
|
|
271
|
+
|
|
272
|
+
```vue
|
|
273
|
+
<script setup lang="ts">
|
|
274
|
+
import 'x-next/style.css';
|
|
275
|
+
import { ResizeBox, TrendChart } from 'x-next';
|
|
276
|
+
import { ref } from 'vue';
|
|
277
|
+
|
|
278
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
279
|
+
const resizeWidth = ref(320);
|
|
280
|
+
const resizeHeight = ref(56);
|
|
281
|
+
</script>
|
|
282
|
+
<template>
|
|
283
|
+
<ResizeBox
|
|
284
|
+
v-model:width="resizeWidth"
|
|
285
|
+
v-model:height="resizeHeight"
|
|
286
|
+
:min-width="120"
|
|
287
|
+
:max-width="480"
|
|
288
|
+
:directions="['right', 'bottom']"
|
|
289
|
+
class="chart-box"
|
|
290
|
+
>
|
|
291
|
+
<TrendChart :dataset="dataset" :height="'100%'" status="primary" />
|
|
292
|
+
</ResizeBox>
|
|
293
|
+
</template>
|
|
294
|
+
<style scoped>
|
|
295
|
+
.chart-box {
|
|
296
|
+
border: 1px solid var(--x-color-border-subtle);
|
|
297
|
+
border-radius: 6px;
|
|
298
|
+
}
|
|
299
|
+
</style>
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### 无障碍
|
|
303
|
+
|
|
304
|
+
设置 `aria-label` 后根节点会输出 `role="img"` 与可访问名称,屏幕阅读器可以播报图表用途。
|
|
305
|
+
|
|
306
|
+
```vue
|
|
307
|
+
<script setup lang="ts">
|
|
308
|
+
import 'x-next/style.css';
|
|
309
|
+
import { TrendChart } from 'x-next';
|
|
310
|
+
const dataset = [12, 18, 14, 24, 32, 28, 36, 42];
|
|
311
|
+
</script>
|
|
312
|
+
<template>
|
|
313
|
+
<TrendChart
|
|
314
|
+
:dataset="dataset"
|
|
315
|
+
:height="56"
|
|
316
|
+
ariaLabel="近七日订单量趋势"
|
|
317
|
+
interactive
|
|
318
|
+
tooltip
|
|
319
|
+
/>
|
|
320
|
+
</template>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### 使用说明
|
|
324
|
+
|
|
325
|
+
- 默认高度 60px,无需外部容器样式;需要更高时通过 `height` 指定。
|
|
326
|
+
- 不带网格与坐标轴(`grid` / `labels` 自 1.8.0 起废弃、不再渲染):需要读数请改用 [LineChart](./line-chart.md),或在当前尺寸下开 `tooltip`。
|
|
327
|
+
- 空数组会渲染空态文案,不会抛错。
|
|
328
|
+
- 单点数据会渲染为一个点,且不渲染填充。
|
|
329
|
+
- 所有值相同时,趋势线绘制在图表中线。
|
|
330
|
+
- `min` / `max` 锁定数据域后,超出部分被裁剪而非扩展区间,适合区间放大与多图对齐口径。
|
|
331
|
+
- 容器尺寸变化会自动重算;初始隐藏在 `display: none` 中的图表,在变为可见后同样会重新计算尺寸。
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
返回 [AI 索引](../index.md)。先查本页与 [本地 API](./trend-chart-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
|
+
# Trigger 完整公开 API
|
|
3
|
+
|
|
4
|
+
适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
|
|
5
|
+
|
|
6
|
+
从同版本构建的公开声明、运行时 props/emits 和显式 expose 生成。运行时导入始终使用 `x-next`,声明路径仅作定位。插槽类型未细化时,具体槽名与作用域见本地用法示例。
|
|
7
|
+
|
|
8
|
+
## Trigger API
|
|
9
|
+
|
|
10
|
+
公开声明:`dist/components/trigger/index.d.ts`。 类型中的 undefined 表示可省略;原始 prop 默认值不等于继承配置或服务默认值。
|
|
11
|
+
|
|
12
|
+
### Props
|
|
13
|
+
|
|
14
|
+
| 名称 | 用途 | 公开类型 | 必填 | 声明默认值 |
|
|
15
|
+
| --- | --- | --- | --- | --- |
|
|
16
|
+
| popupVisible | 弹出框是否可见,支持 v-model:popup-visible | undefined | false | true | 否 | undefined |
|
|
17
|
+
| defaultPopupVisible | 默认是否可见,非受控模式 | undefined | false | true | 否 | false |
|
|
18
|
+
| trigger | 触发方式 | undefined | "click" | "hover" | "focus" | "contextMenu" | ("click" | "hover" | "focus" | "contextMenu")[] | 否 | "hover" |
|
|
19
|
+
| position | 弹出位置 | undefined | "top" | "bottom" | "right" | "left" | "tl" | "tr" | "bl" | "br" | "lt" | "rt" | "lb" | "rb" | 否 | "bottom" |
|
|
20
|
+
| disabled | 是否禁用 | undefined | false | true | 否 | false |
|
|
21
|
+
| popupOffset | 弹出框偏移 | undefined | number | 否 | 0 |
|
|
22
|
+
| popupTranslate | 弹出框移动距离 | undefined | [number, number] | { top?: [number, number] | undefined; bottom?: [number, number] | undefined; right?: [number, number] | undefined; left?: [number, number] | undefined; tl?: [number, number] | undefined; tr?: [number, number] | undefined; bl?: [number, number] | undefined; br?: [number, number] | undefined; lt?: [number, number] | undefined; rt?: [number, number] | undefined; lb?: [number, number] | undefined; rb?: [number, number] | undefined; } | 否 | 未声明 |
|
|
23
|
+
| showArrow | 是否显示箭头 | undefined | false | true | 否 | false |
|
|
24
|
+
| alignPoint | 是否跟随鼠标位置,常用于右键菜单 | undefined | false | true | 否 | false |
|
|
25
|
+
| popupHoverStay | hover 触发时移入浮层是否保持显示 | undefined | false | true | 否 | true |
|
|
26
|
+
| blurToClose | focus 触发时失焦是否关闭 | undefined | false | true | 否 | true |
|
|
27
|
+
| clickToClose | 点击触发器时是否允许关闭 | undefined | false | true | 否 | true |
|
|
28
|
+
| clickOutsideToClose | 点击外部是否关闭 | undefined | false | true | 否 | true |
|
|
29
|
+
| unmountOnClose | 关闭时是否卸载弹出框 | undefined | false | true | 否 | true |
|
|
30
|
+
| contentClass | 弹出内容类名 | undefined | string | { [x: string]: any; } | unknown[] | 否 | 未声明 |
|
|
31
|
+
| contentStyle | 弹出内容样式 | undefined | CSSProperties | 否 | 未声明 |
|
|
32
|
+
| arrowClass | 箭头类名 | undefined | string | { [x: string]: any; } | unknown[] | 否 | 未声明 |
|
|
33
|
+
| arrowStyle | 箭头样式 | undefined | CSSProperties | 否 | 未声明 |
|
|
34
|
+
| popupStyle | 弹出框定位节点样式 | undefined | CSSProperties | 否 | 未声明 |
|
|
35
|
+
| animationName | 弹出动画名称 | undefined | string | 否 | "x-fade-in" |
|
|
36
|
+
| duration | 动画持续时间 | undefined | number | { enter: number; leave: number; } | 否 | 未声明 |
|
|
37
|
+
| mouseEnterDelay | mouseenter 延迟,单位毫秒 | undefined | number | 否 | 100 |
|
|
38
|
+
| mouseLeaveDelay | mouseleave 延迟,单位毫秒 | undefined | number | 否 | 100 |
|
|
39
|
+
| focusDelay | focus 延迟,单位毫秒 | undefined | number | 否 | 0 |
|
|
40
|
+
| autoFitPopupWidth | 是否将弹出框宽度设为触发器宽度 | undefined | false | true | 否 | false |
|
|
41
|
+
| autoFitPopupMinWidth | 是否将弹出框最小宽度设为触发器宽度 | undefined | false | true | 否 | false |
|
|
42
|
+
| autoFixPosition | 触发器尺寸变化时是否重新定位 | undefined | false | true | 否 | true |
|
|
43
|
+
| popupContainer | 弹出框挂载容器 | undefined | string | HTMLElement | 否 | 未声明 |
|
|
44
|
+
| updateAtScroll | 容器滚动时是否更新浮层位置 | undefined | false | true | 否 | false |
|
|
45
|
+
| autoFitTransformOrigin | 是否自动调整 transform-origin | undefined | false | true | 否 | false |
|
|
46
|
+
| hideEmpty | 内容为空时是否隐藏 | undefined | false | true | 否 | false |
|
|
47
|
+
| openedClass | 打开时给触发元素添加的类名 | undefined | string | { [x: string]: any; } | unknown[] | 否 | 未声明 |
|
|
48
|
+
| autoFitPosition | 是否自动调整位置适配视口 | undefined | false | true | 否 | true |
|
|
49
|
+
| renderToBody | 是否挂载到 body | undefined | false | true | 否 | true |
|
|
50
|
+
| preventFocus | 点击弹出层元素时是否阻止获取焦点 | undefined | false | true | 否 | false |
|
|
51
|
+
| scrollToClose | 滚动时是否关闭 | undefined | false | true | 否 | false |
|
|
52
|
+
| scrollToCloseDistance | 滚动关闭阈值 | undefined | number | 否 | 0 |
|
|
53
|
+
|
|
54
|
+
### Events
|
|
55
|
+
|
|
56
|
+
| 事件 | 用途 | 监听器签名(即事件参数) |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| update:popupVisible | 弹出框显隐变化时触发 | undefined | (visible: boolean) => any |
|
|
59
|
+
| popupVisibleChange | 弹出框显隐变化时触发 | undefined | (visible: boolean) => any |
|
|
60
|
+
| show | 显示动画结束后触发 | undefined | () => any |
|
|
61
|
+
| hide | 隐藏动画结束后触发 | undefined | () => any |
|
|
62
|
+
| resize | 内部尺寸变化时触发 | undefined | () => any |
|
|
63
|
+
|
|
64
|
+
### Slots
|
|
65
|
+
|
|
66
|
+
| 名称 | 用途 | 公开类型 |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| default | 触发元素 | any |
|
|
69
|
+
| content | 弹出内容 | any |
|
|
70
|
+
|
|
71
|
+
### 实例方法
|
|
72
|
+
|
|
73
|
+
没有检索到显式 expose 或 Options API methods 的公开方法;不把 setup 内部函数当成稳定实例 API。
|
|
74
|
+
|
|
75
|
+
### 关联类型定义
|
|
76
|
+
|
|
77
|
+
以下摘自本组件族声明,供查阅嵌套配置;运行时和值类型均以根入口可导出项为准。
|
|
78
|
+
|
|
79
|
+
```typescript-reference
|
|
80
|
+
type TriggerPopupTranslate = [number, number] | {
|
|
81
|
+
[key in TriggerPosition]?: [number, number];
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
interface TriggerProps {
|
|
85
|
+
popupVisible?: boolean;
|
|
86
|
+
defaultPopupVisible?: boolean;
|
|
87
|
+
trigger?: TriggerEvent;
|
|
88
|
+
position?: TriggerPosition;
|
|
89
|
+
disabled?: boolean;
|
|
90
|
+
popupOffset?: number;
|
|
91
|
+
popupTranslate?: TriggerPopupTranslate;
|
|
92
|
+
showArrow?: boolean;
|
|
93
|
+
alignPoint?: boolean;
|
|
94
|
+
popupHoverStay?: boolean;
|
|
95
|
+
blurToClose?: boolean;
|
|
96
|
+
clickToClose?: boolean;
|
|
97
|
+
clickOutsideToClose?: boolean;
|
|
98
|
+
scrollToClose?: boolean;
|
|
99
|
+
scrollToCloseDistance?: number;
|
|
100
|
+
unmountOnClose?: boolean;
|
|
101
|
+
contentClass?: any;
|
|
102
|
+
contentStyle?: CSSProperties;
|
|
103
|
+
arrowClass?: any;
|
|
104
|
+
arrowStyle?: CSSProperties;
|
|
105
|
+
popupStyle?: CSSProperties;
|
|
106
|
+
animationName?: string;
|
|
107
|
+
duration?: number | {
|
|
108
|
+
enter: number;
|
|
109
|
+
leave: number;
|
|
110
|
+
};
|
|
111
|
+
mouseEnterDelay?: number;
|
|
112
|
+
mouseLeaveDelay?: number;
|
|
113
|
+
focusDelay?: number;
|
|
114
|
+
autoFitPopupWidth?: boolean;
|
|
115
|
+
autoFitPopupMinWidth?: boolean;
|
|
116
|
+
autoFixPosition?: boolean;
|
|
117
|
+
popupContainer?: string | HTMLElement;
|
|
118
|
+
updateAtScroll?: boolean;
|
|
119
|
+
autoFitPosition?: boolean;
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
返回 [Trigger 用法](./trigger.md)。
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
|
+
# Trigger AI 使用
|
|
3
|
+
|
|
4
|
+
适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
|
|
5
|
+
|
|
6
|
+
先读 [通用接入](../core.md)。公开导出:`Trigger`;主要模型:v-model:popup-visible。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./trigger-api.md),包含本组件族全部子组件和别名。
|
|
7
|
+
|
|
8
|
+
按需样式:`x-next/style/trigger`(包含 base.css、trigger.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
|
|
9
|
+
|
|
10
|
+
## 场景用法
|
|
11
|
+
|
|
12
|
+
以下示例从本地 `src/docs/components/trigger.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./trigger-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
|
|
13
|
+
|
|
14
|
+
### 用途与选型
|
|
15
|
+
|
|
16
|
+
Trigger 是底层浮层 primitive,主要给 x-next 内部组件和高级封装使用。普通业务展示浮动卡片时,请优先使用 [Popover 气泡卡片](./popover.md)。
|
|
17
|
+
|
|
18
|
+
Trigger 负责处理触发事件、显隐状态、浮层定位、Teleport、箭头、滚动更新和外部点击关闭。它不提供业务语义,也不提供卡片视觉规范。
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### 何时使用
|
|
22
|
+
|
|
23
|
+
- 你正在封装新的浮层组件,例如 Tooltip、Dropdown、Popover、Popconfirm、SelectDropdown。
|
|
24
|
+
- 你需要完全接管浮层内容结构和样式,不希望使用 Popover 的卡片语义。
|
|
25
|
+
- 你需要直接控制底层定位行为,例如 `alignPoint`、`popupContainer`、`updateAtScroll`、`scrollToClose`。
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### 不推荐使用
|
|
29
|
+
|
|
30
|
+
- 展示普通说明卡片:使用 `Popover`。
|
|
31
|
+
- 展示纯文字提示:使用 `Tooltip`。
|
|
32
|
+
- 展示操作菜单:使用 `Dropdown`。
|
|
33
|
+
- 展示二次确认:使用 `Popconfirm`。
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### 与 Popover 的区别
|
|
37
|
+
|
|
38
|
+
| 维度 | Popover | Trigger |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| 用户心智 | 气泡卡片组件 | 底层触发定位 primitive |
|
|
41
|
+
| 是否主推给业务用户 | 是 | 否 |
|
|
42
|
+
| 是否有默认卡片样式 | 有 | 无 |
|
|
43
|
+
| 是否提供 `title` / `content` 语义 | 有 | 无 |
|
|
44
|
+
| 主要用途 | 展示富内容浮层 | 封装 Tooltip、Dropdown、Popover 等组件 |
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### 基础封装示例
|
|
48
|
+
|
|
49
|
+
下面示例展示 Trigger 作为底层能力的使用方式。业务代码通常不需要直接这样写。
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<script setup lang="ts">
|
|
53
|
+
import 'x-next/style.css';
|
|
54
|
+
import { Trigger, Button } from 'x-next';
|
|
55
|
+
|
|
56
|
+
</script>
|
|
57
|
+
<template>
|
|
58
|
+
<Trigger trigger="click" show-arrow>
|
|
59
|
+
<Button>底层触发器</Button>
|
|
60
|
+
<template #content>
|
|
61
|
+
<div class="custom-popup">完全自定义的浮层内容</div>
|
|
62
|
+
</template>
|
|
63
|
+
</Trigger>
|
|
64
|
+
</template>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 受控显隐与事件
|
|
68
|
+
|
|
69
|
+
`disabled` 阻止触发事件;受控 prop 仍以父级值为准。外部直接赋值不派发触发事件。
|
|
70
|
+
|
|
71
|
+
```vue
|
|
72
|
+
<script setup lang="ts">
|
|
73
|
+
import 'x-next/style.css';
|
|
74
|
+
import { Button, Checkbox, Trigger } from 'x-next';
|
|
75
|
+
import { ref } from 'vue';
|
|
76
|
+
const visible = ref(false);
|
|
77
|
+
const disabled = ref(false);
|
|
78
|
+
const log = ref('等待开关');
|
|
79
|
+
</script>
|
|
80
|
+
<template>
|
|
81
|
+
<Button @click="visible = !visible">外部切换</Button>
|
|
82
|
+
<Checkbox v-model="disabled">禁用触发</Checkbox>
|
|
83
|
+
<Trigger v-model:popup-visible="visible" trigger="click" :disabled="disabled"
|
|
84
|
+
@popup-visible-change="(value) => log = `visible: ${value}`">
|
|
85
|
+
<Button>点击触发</Button>
|
|
86
|
+
<template #content><div class="popup">受控浮层</div></template>
|
|
87
|
+
</Trigger>
|
|
88
|
+
<p role="status">{{ log }};当前 {{ visible ? '打开' : '关闭' }}</p>
|
|
89
|
+
</template>
|
|
90
|
+
<style scoped>
|
|
91
|
+
.popup { padding: 12px; background: var(--x-color-bg-elevated); border: 1px solid var(--x-color-border-default); }
|
|
92
|
+
</style>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 打开中切换挂载容器
|
|
96
|
+
|
|
97
|
+
先打开浮层,再切换 A / B,浮层会迁移到当前容器并重新定位。
|
|
98
|
+
|
|
99
|
+
容器不存在时回退 body;容器延迟出现后,可以更新 `popupContainer` 或再次打开,让组件重新解析目标。
|
|
100
|
+
|
|
101
|
+
```vue
|
|
102
|
+
<script setup lang="ts">
|
|
103
|
+
import 'x-next/style.css';
|
|
104
|
+
import { Button, Trigger } from 'x-next';
|
|
105
|
+
import { ref } from 'vue';
|
|
106
|
+
const container = ref('#popup-host-a');
|
|
107
|
+
</script>
|
|
108
|
+
<template>
|
|
109
|
+
<Button @click="container = '#popup-host-a'">容器 A</Button>
|
|
110
|
+
<Button @click="container = '#popup-host-b'">容器 B</Button>
|
|
111
|
+
<Trigger trigger="click" :popup-container="container" :click-outside-to-close="false">
|
|
112
|
+
<Button>打开 / 关闭</Button>
|
|
113
|
+
<template #content><div class="popup">挂载到 {{ container }}</div></template>
|
|
114
|
+
</Trigger>
|
|
115
|
+
<div id="popup-host-a" class="host">容器 A</div>
|
|
116
|
+
<div id="popup-host-b" class="host">容器 B</div>
|
|
117
|
+
</template>
|
|
118
|
+
<style scoped>
|
|
119
|
+
.host { position: relative; min-height: 60px; margin-top: 12px; border: 1px dashed var(--x-color-border-default); }
|
|
120
|
+
.popup { padding: 12px; background: var(--x-color-bg-elevated); border: 1px solid var(--x-color-border-default); }
|
|
121
|
+
</style>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 聚焦触发
|
|
125
|
+
|
|
126
|
+
```vue
|
|
127
|
+
<script setup lang="ts">
|
|
128
|
+
import 'x-next/style.css';
|
|
129
|
+
import { Trigger } from 'x-next';
|
|
130
|
+
|
|
131
|
+
</script>
|
|
132
|
+
<template>
|
|
133
|
+
<Trigger trigger="focus">
|
|
134
|
+
<input aria-label="聚焦触发示例" placeholder="Tab 或点击聚焦" />
|
|
135
|
+
<template #content><div>移开焦点后关闭</div></template>
|
|
136
|
+
</Trigger>
|
|
137
|
+
</template>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 右键与指针位置
|
|
141
|
+
|
|
142
|
+
```vue
|
|
143
|
+
<script setup lang="ts">
|
|
144
|
+
import 'x-next/style.css';
|
|
145
|
+
import { Trigger } from 'x-next';
|
|
146
|
+
|
|
147
|
+
</script>
|
|
148
|
+
<template>
|
|
149
|
+
<Trigger trigger="contextMenu" align-point>
|
|
150
|
+
<button type="button">在这里点右键</button>
|
|
151
|
+
<template #content><div>跟随右键位置,点击外部关闭</div></template>
|
|
152
|
+
</Trigger>
|
|
153
|
+
</template>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### 滚动与位置更新
|
|
157
|
+
|
|
158
|
+
```vue
|
|
159
|
+
<script setup lang="ts">
|
|
160
|
+
import 'x-next/style.css';
|
|
161
|
+
import { Trigger, Button } from 'x-next';
|
|
162
|
+
|
|
163
|
+
</script>
|
|
164
|
+
<template>
|
|
165
|
+
<div class="scroll">
|
|
166
|
+
<div class="content">
|
|
167
|
+
<Trigger trigger="click" update-at-scroll>
|
|
168
|
+
<Button>滚动时保持定位</Button>
|
|
169
|
+
<template #content><div>浮层跟随触发点</div></template>
|
|
170
|
+
</Trigger>
|
|
171
|
+
<Trigger trigger="click" scroll-to-close :scroll-to-close-distance="20">
|
|
172
|
+
<Button>滚动 20px 关闭</Button>
|
|
173
|
+
<template #content><div>超过阈值后关闭</div></template>
|
|
174
|
+
</Trigger>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
</template>
|
|
178
|
+
<style scoped>
|
|
179
|
+
.scroll { height: 120px; overflow: auto; }
|
|
180
|
+
.content { min-height: 360px; padding: 24px; }
|
|
181
|
+
</style>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
返回 [AI 索引](../index.md)。先查本页与 [本地 API](./trigger-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。
|