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
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
2
|
# PieChart AI 使用
|
|
3
3
|
|
|
4
|
-
适用版本:x-next@1.
|
|
4
|
+
适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
|
|
5
5
|
|
|
6
|
-
先读 [通用接入](../core.md)。公开导出:`PieChart
|
|
6
|
+
先读 [通用接入](../core.md)。公开导出:`PieChart`;主要模型:无。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./pie-chart-api.md),包含本组件族全部子组件和别名。
|
|
7
7
|
|
|
8
8
|
按需样式:`x-next/style/pie-chart`(包含 base.css、pie-chart.css、spin.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
|
|
9
9
|
|
|
10
|
+
## 已核验行为与示例
|
|
11
|
+
|
|
10
12
|
[组件文档与 live demo](https://x-next.yjmf.com/components/pie-chart)。表达占比:`data` 是 `{ name, value }[]`,值按**可见**分片求和换算角度。`innerRadius="62%"` 渲染成环形并在中心显示合计(推荐形态,信息密度更高);数字形式的 `innerRadius` 按 px。负值、0 与非有限数会被跳过,不计入总量。
|
|
11
13
|
|
|
12
14
|
**类别要收敛**:饼图超过 7 个分片就难以阅读,先按值排序、把尾部合并成「其他」再传入(下面给出写法)。需要精确比较大小改用 BarChart,需要看随时间的变化改用 LineChart。
|
|
@@ -52,4 +54,244 @@ function onItemClick(item: { name: string; value: number; percent: number; forma
|
|
|
52
54
|
</template>
|
|
53
55
|
```
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
## 场景用法
|
|
58
|
+
|
|
59
|
+
以下示例从本地 `src/docs/components/pie-chart.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./pie-chart-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
|
|
60
|
+
|
|
61
|
+
### 用途与选型
|
|
62
|
+
|
|
63
|
+
用于展示各部分在整体中的占比:支持饼图与环形图、中心内容、外围标签与图例联动。
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### 何时使用
|
|
67
|
+
|
|
68
|
+
- 需要表达「各部分占整体的比例」,且只关心少数几个主要类别(建议不超过 7 个)。
|
|
69
|
+
- 数据总和有意义(如各类别调用量、各渠道订单数)。
|
|
70
|
+
- 环形模式适合在中心放一个合计值或关键指标,信息密度更高。
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### 什么时候不要用
|
|
74
|
+
|
|
75
|
+
饼图表达力弱:角度比长度更难精确比较,分片一多就会退化成一圈小色块。
|
|
76
|
+
|
|
77
|
+
| 情况 | 改用 |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| 类别超过 7 个 | 堆叠柱状([BarChart](./bar-chart.md) 的 `stack`),或先把小项合并为「其他」 |
|
|
80
|
+
| 需要精确比较各类别大小 | [BarChart 柱状趋势图](./bar-chart.md) 并排柱状 |
|
|
81
|
+
| 要表达随时间的变化 | [LineChart 折线图](./line-chart.md) |
|
|
82
|
+
| 只有一个占比(如使用率 62%) | 用 [Progress 进度条](./progress.md) 或环形进度,不要用两个分片的饼图 |
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### 基础用法
|
|
86
|
+
|
|
87
|
+
`data` 为 `{ name, value }[]`;值为负、为 0 或非有限数会被跳过,不计入总量。
|
|
88
|
+
|
|
89
|
+
```vue
|
|
90
|
+
<script setup lang="ts">
|
|
91
|
+
import 'x-next/style.css';
|
|
92
|
+
import { PieChart } from 'x-next';
|
|
93
|
+
import { ref } from 'vue';
|
|
94
|
+
|
|
95
|
+
const data = ref([
|
|
96
|
+
{ name: 'deepseek-flash', value: 13260000 },
|
|
97
|
+
{ name: 'gpt-4o-mini', value: 4820000 },
|
|
98
|
+
{ name: 'claude-haiku', value: 2140000 },
|
|
99
|
+
]);
|
|
100
|
+
const formatCompact = (value: number) => `${(value / 10000).toFixed(1)} 万`;
|
|
101
|
+
</script>
|
|
102
|
+
<template>
|
|
103
|
+
<PieChart :data="data" :value-formatter="formatCompact" ariaLabel="各模型 Token 占比" />
|
|
104
|
+
</template>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 环形与中心内容
|
|
108
|
+
|
|
109
|
+
`innerRadius` 大于 0 时渲染为环形:数字按 px,`'62%'` 按外半径比例。环形默认在中心展示合计,也可用 `center` 插槽自定义。
|
|
110
|
+
|
|
111
|
+
```vue
|
|
112
|
+
<script setup lang="ts">
|
|
113
|
+
import 'x-next/style.css';
|
|
114
|
+
import { PieChart } from 'x-next';
|
|
115
|
+
import { ref } from 'vue';
|
|
116
|
+
|
|
117
|
+
const innerRadius = ref('62%');
|
|
118
|
+
const data = ref([
|
|
119
|
+
{ name: 'Web', value: 4280 },
|
|
120
|
+
{ name: 'iOS', value: 3160 },
|
|
121
|
+
{ name: 'Android', value: 2870 },
|
|
122
|
+
{ name: 'API', value: 1520 },
|
|
123
|
+
]);
|
|
124
|
+
const formatCalls = (value: number) => `${value} 次`;
|
|
125
|
+
</script>
|
|
126
|
+
<template>
|
|
127
|
+
<PieChart
|
|
128
|
+
:data="data"
|
|
129
|
+
:inner-radius="innerRadius"
|
|
130
|
+
:value-formatter="formatCalls"
|
|
131
|
+
/>
|
|
132
|
+
</template>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 自定义中心
|
|
136
|
+
|
|
137
|
+
`center` 插槽接管环形中心,可放合计之外的内容(如环比的箭头与增幅)。
|
|
138
|
+
|
|
139
|
+
```vue
|
|
140
|
+
<script setup lang="ts">
|
|
141
|
+
import 'x-next/style.css';
|
|
142
|
+
import { PieChart } from 'x-next';
|
|
143
|
+
import { ref } from 'vue';
|
|
144
|
+
|
|
145
|
+
const data = ref([
|
|
146
|
+
{ name: 'Web', value: 4280 },
|
|
147
|
+
{ name: 'iOS', value: 3160 },
|
|
148
|
+
{ name: 'Android', value: 2870 },
|
|
149
|
+
{ name: 'API', value: 1520 },
|
|
150
|
+
]);
|
|
151
|
+
</script>
|
|
152
|
+
<template>
|
|
153
|
+
<PieChart :data="data" inner-radius="62%">
|
|
154
|
+
<template #center="{ total, formatValue }">
|
|
155
|
+
<text x="50%" y="46%" text-anchor="middle">总调用量</text>
|
|
156
|
+
<text x="50%" y="56%" text-anchor="middle">{{ formatValue(total) }}</text>
|
|
157
|
+
</template>
|
|
158
|
+
</PieChart>
|
|
159
|
+
</template>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 类别过多时合并「其他」
|
|
163
|
+
|
|
164
|
+
饼图不宜超过 7 个分片。先按值排序,把尾部合并成一项再传入,是最省事也最可控的做法。
|
|
165
|
+
|
|
166
|
+
```vue
|
|
167
|
+
<script setup lang="ts">
|
|
168
|
+
import 'x-next/style.css';
|
|
169
|
+
import { PieChart } from 'x-next';
|
|
170
|
+
import { computed, ref } from 'vue';
|
|
171
|
+
|
|
172
|
+
const raw = ref([
|
|
173
|
+
{ name: 'search', value: 820 },
|
|
174
|
+
{ name: 'read_file', value: 610 },
|
|
175
|
+
{ name: 'write_file', value: 430 },
|
|
176
|
+
{ name: 'run_shell', value: 320 },
|
|
177
|
+
{ name: 'browse', value: 210 },
|
|
178
|
+
{ name: 'exec_python', value: 180 },
|
|
179
|
+
{ name: 'grep', value: 140 },
|
|
180
|
+
{ name: 'edit', value: 110 },
|
|
181
|
+
{ name: 'todo_write', value: 90 },
|
|
182
|
+
]);
|
|
183
|
+
const LIMIT = 5;
|
|
184
|
+
// 取前 N 项,其余合并为「其他」
|
|
185
|
+
const data = computed(() => {
|
|
186
|
+
const sorted = [...raw.value].sort((a, b) => b.value - a.value);
|
|
187
|
+
const top = sorted.slice(0, LIMIT);
|
|
188
|
+
const rest = sorted.slice(LIMIT).reduce((sum, item) => sum + item.value, 0);
|
|
189
|
+
return rest > 0 ? [...top, { name: '其他', value: rest }] : top;
|
|
190
|
+
});
|
|
191
|
+
const formatCalls = (value: number) => `${value} 次`;
|
|
192
|
+
</script>
|
|
193
|
+
<template>
|
|
194
|
+
<PieChart :data="data" inner-radius="62%" :value-formatter="formatCalls" legend />
|
|
195
|
+
</template>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### 图例联动与点击事件
|
|
199
|
+
|
|
200
|
+
`legend` 开启后,图例项展示数值与占比,点击可临时隐藏分片——剩余分片会重新分配角度、中心合计同步更新。点击分片触发 `item-click`。
|
|
201
|
+
|
|
202
|
+
```vue
|
|
203
|
+
<script setup lang="ts">
|
|
204
|
+
import 'x-next/style.css';
|
|
205
|
+
import { PieChart } from 'x-next';
|
|
206
|
+
import { ref } from 'vue';
|
|
207
|
+
|
|
208
|
+
const data = ref([
|
|
209
|
+
{ name: 'Web', value: 4280 },
|
|
210
|
+
{ name: 'iOS', value: 3160 },
|
|
211
|
+
{ name: 'Android', value: 2870 },
|
|
212
|
+
{ name: 'API', value: 1520 },
|
|
213
|
+
]);
|
|
214
|
+
const clickLog = ref('尚未点击分片');
|
|
215
|
+
const visibleCount = ref(4);
|
|
216
|
+
const onItemClick = (data: { name: string; value: number; percent: number; formatPercent: (p: number) => string }) => {
|
|
217
|
+
clickLog.value = `${data.name}:${data.value}(${data.formatPercent(data.percent)})`;
|
|
218
|
+
};
|
|
219
|
+
const onLegendChange = (indexes: number[]) => {
|
|
220
|
+
visibleCount.value = indexes.length;
|
|
221
|
+
};
|
|
222
|
+
</script>
|
|
223
|
+
<template>
|
|
224
|
+
<PieChart
|
|
225
|
+
:data="data"
|
|
226
|
+
inner-radius="62%"
|
|
227
|
+
legend
|
|
228
|
+
@item-click="onItemClick"
|
|
229
|
+
@legend-change="onLegendChange"
|
|
230
|
+
/>
|
|
231
|
+
<p>{{ clickLog }}</p>
|
|
232
|
+
</template>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### 自定义提示
|
|
236
|
+
|
|
237
|
+
`tooltip` 插槽可显示调用次数、占比与环比等组合信息。
|
|
238
|
+
|
|
239
|
+
```vue
|
|
240
|
+
<script setup lang="ts">
|
|
241
|
+
import 'x-next/style.css';
|
|
242
|
+
import { PieChart } from 'x-next';
|
|
243
|
+
import { ref } from 'vue';
|
|
244
|
+
|
|
245
|
+
const data = ref([
|
|
246
|
+
{ name: 'Web', value: 4280 },
|
|
247
|
+
{ name: 'iOS', value: 3160 },
|
|
248
|
+
{ name: 'Android', value: 2870 },
|
|
249
|
+
{ name: 'API', value: 1520 },
|
|
250
|
+
]);
|
|
251
|
+
const formatCalls = (value: number) => `${value} 次`;
|
|
252
|
+
</script>
|
|
253
|
+
<template>
|
|
254
|
+
<PieChart :data="data" inner-radius="62%" :value-formatter="formatCalls">
|
|
255
|
+
<template #tooltip="{ name, value, percent, formatValue, formatPercent }">
|
|
256
|
+
<div style="font-weight: 500">{{ name }}</div>
|
|
257
|
+
<div>{{ formatValue(value) }} · {{ formatPercent(percent) }}</div>
|
|
258
|
+
</template>
|
|
259
|
+
</PieChart>
|
|
260
|
+
</template>
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### 加载与空数据
|
|
264
|
+
|
|
265
|
+
`loading` 覆盖加载遮罩;没有正数分片时显示空态,可用 `empty` 插槽替换。
|
|
266
|
+
|
|
267
|
+
```vue
|
|
268
|
+
<script setup lang="ts">
|
|
269
|
+
import 'x-next/style.css';
|
|
270
|
+
import { PieChart } from 'x-next';
|
|
271
|
+
import { ref } from 'vue';
|
|
272
|
+
|
|
273
|
+
const loading = ref(true);
|
|
274
|
+
const data = ref([
|
|
275
|
+
{ name: 'Web', value: 4280 },
|
|
276
|
+
{ name: 'iOS', value: 3160 },
|
|
277
|
+
]);
|
|
278
|
+
</script>
|
|
279
|
+
<template>
|
|
280
|
+
<PieChart :data="data" inner-radius="62%" :loading="loading">
|
|
281
|
+
<template #empty>该时段没有调用记录</template>
|
|
282
|
+
</PieChart>
|
|
283
|
+
</template>
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### 交互说明
|
|
287
|
+
|
|
288
|
+
- **占比计算**:按**可见**分片求和;隐藏某个分片后,其余分片重新分配角度,中心合计同步更新。
|
|
289
|
+
- **单分片**:只有一个可见分片时不做缝隙,渲染为完整圆(否则会被切掉一小角,看起来像渲染错误)。
|
|
290
|
+
- **小分片标签**:占比低于 4% 的分片不绘制外围标签,避免标签挤在一起;`tooltip` 与 `legend` 仍可查看其数值。
|
|
291
|
+
- **零值处理**:值为 0、负数或非有限数的分片不渲染,也不计入总量。
|
|
292
|
+
- **键盘导航**:画布可聚焦,左右方向键在分片间循环移动、Home / End 跳到首尾、Esc 关闭提示;键盘导航时通过 `aria-live` 播报。
|
|
293
|
+
- **性能**:分片数量建议控制在 7 个以内,既符合可视化最佳实践,也避免 `stroke` 描边在细长分片上糊成一片。
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
返回 [AI 索引](../index.md)。先查本页与 [本地 API](./pie-chart-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
|
+
# Popconfirm 完整公开 API
|
|
3
|
+
|
|
4
|
+
适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
|
|
5
|
+
|
|
6
|
+
从同版本构建的公开声明、运行时 props/emits 和显式 expose 生成。运行时导入始终使用 `x-next`,声明路径仅作定位。插槽类型未细化时,具体槽名与作用域见本地用法示例。
|
|
7
|
+
|
|
8
|
+
## Popconfirm API
|
|
9
|
+
|
|
10
|
+
公开声明:`dist/components/popconfirm/index.d.ts`。 类型中的 undefined 表示可省略;原始 prop 默认值不等于继承配置或服务默认值。
|
|
11
|
+
|
|
12
|
+
### Props
|
|
13
|
+
|
|
14
|
+
| 名称 | 用途 | 公开类型 | 必填 | 声明默认值 |
|
|
15
|
+
| --- | --- | --- | --- | --- |
|
|
16
|
+
| modelValue | 是否显示气泡,未传时使用内部状态 | undefined | false | true | 否 | undefined |
|
|
17
|
+
| defaultVisible | 默认是否显示气泡,非受控模式使用 | undefined | false | true | 否 | false |
|
|
18
|
+
| disabled | 是否禁用 | undefined | false | true | 否 | false |
|
|
19
|
+
| width | 气泡宽度 | undefined | string | number | 否 | 150 |
|
|
20
|
+
| type | 类型 | undefined | "success" | "warning" | "strong" | "info" | "primary" | "danger" | 否 | "danger" |
|
|
21
|
+
| content | 确认内容 | undefined | string | number | 否 | 未声明 |
|
|
22
|
+
| position | 弹出位置 | undefined | "top" | "bottom" | "right" | "left" | "tl" | "tr" | "bl" | "br" | "lt" | "rt" | "lb" | "rb" | 否 | "top" |
|
|
23
|
+
| okText | 确认按钮文案 | undefined | string | 否 | undefined |
|
|
24
|
+
| cancelText | 取消按钮文案 | undefined | string | 否 | undefined |
|
|
25
|
+
| okLoading | 确认按钮是否为 loading | undefined | false | true | 否 | false |
|
|
26
|
+
| okButtonProps | 确认按钮 props | undefined | { disabled?: boolean; block?: boolean; loading?: boolean; loadingFill?: boolean; debounce?: number; shape?: ButtonShape; link?: boolean; type?: ButtonTypes; htmlType?: ButtonHtmlType; status?: ButtonStatus; plain?: boolean; size?: ButtonSize; border?: boolean; narrow?: boolean; } | 否 | 未声明 |
|
|
27
|
+
| cancelButtonProps | 取消按钮 props | undefined | { disabled?: boolean; block?: boolean; loading?: boolean; loadingFill?: boolean; debounce?: number; shape?: ButtonShape; link?: boolean; type?: ButtonTypes; htmlType?: ButtonHtmlType; status?: ButtonStatus; plain?: boolean; size?: ButtonSize; border?: boolean; narrow?: boolean; } | 否 | 未声明 |
|
|
28
|
+
| onBeforeOk | 确认前拦截,返回 false 阻止关闭;返回 Promise 时确认按钮进入 loading | undefined | (e: Event) => boolean | void | Promise<boolean | void> | 否 | undefined |
|
|
29
|
+
| onBeforeCancel | 取消前拦截,返回 false 阻止关闭;返回 Promise 时取消按钮进入 loading | undefined | (e: Event) => boolean | void | Promise<boolean | void> | 否 | undefined |
|
|
30
|
+
| renderTo | 弹层挂载容器 | undefined | string | HTMLElement | 否 | 未声明 |
|
|
31
|
+
| renderToBody | 是否挂载到容器;关闭后可配合 Trigger 逻辑控制 Teleport | undefined | false | true | 否 | true |
|
|
32
|
+
| unmountOnClose | 关闭时是否卸载弹层节点 | undefined | false | true | 否 | true |
|
|
33
|
+
| popupClass | 弹层自定义类名 | undefined | string | 否 | 未声明 |
|
|
34
|
+
| contentClass | 弹层内容自定义类名 | undefined | string | { [x: string]: any; } | unknown[] | 否 | 未声明 |
|
|
35
|
+
| contentStyle | 弹层内容自定义样式 | undefined | CSSProperties | 否 | 未声明 |
|
|
36
|
+
| arrowClass | 箭头自定义类名 | undefined | string | { [x: string]: any; } | unknown[] | 否 | 未声明 |
|
|
37
|
+
| arrowStyle | 箭头自定义样式 | undefined | CSSProperties | 否 | 未声明 |
|
|
38
|
+
|
|
39
|
+
### Events
|
|
40
|
+
|
|
41
|
+
| 事件 | 用途 | 监听器签名(即事件参数) |
|
|
42
|
+
| --- | --- | --- |
|
|
43
|
+
| ok | 点击确认且未被拦截时触发 | undefined | (...args: any[]) => any |
|
|
44
|
+
| cancel | 点击取消且未被拦截时触发 | undefined | (...args: any[]) => any |
|
|
45
|
+
| change | 显隐状态变化时触发 | undefined | (...args: any[]) => any |
|
|
46
|
+
| update:modelValue | 显隐状态变化时触发,用于 v-model | undefined | (...args: any[]) => any |
|
|
47
|
+
| beforeCancel | 见场景用法与类型 | undefined | (e: Event) => boolean | void | Promise<boolean | void> |
|
|
48
|
+
| beforeOk | 见场景用法与类型 | undefined | (e: Event) => boolean | void | Promise<boolean | void> |
|
|
49
|
+
|
|
50
|
+
### Slots
|
|
51
|
+
|
|
52
|
+
| 名称 | 用途 | 公开类型 |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| default | 触发元素 | 文档列出的实际插槽;公开类型未细化,作用域见场景用法 |
|
|
55
|
+
| content | 自定义确认内容 | 文档列出的实际插槽;公开类型未细化,作用域见场景用法 |
|
|
56
|
+
| icon | 自定义默认内容布局中的图标 | 文档列出的实际插槽;公开类型未细化,作用域见场景用法 |
|
|
57
|
+
|
|
58
|
+
### 实例方法
|
|
59
|
+
|
|
60
|
+
没有检索到显式 expose 或 Options API methods 的公开方法;不把 setup 内部函数当成稳定实例 API。
|
|
61
|
+
|
|
62
|
+
### 关联类型定义
|
|
63
|
+
|
|
64
|
+
以下摘自本组件族声明,供查阅嵌套配置;运行时和值类型均以根入口可导出项为准。
|
|
65
|
+
|
|
66
|
+
```typescript-reference
|
|
67
|
+
declare const positions: readonly ["top", "tl", "tr", "bottom", "bl", "br", "left", "lt", "lb", "right", "rt", "rb"];
|
|
68
|
+
|
|
69
|
+
type Position = (typeof positions)[number];
|
|
70
|
+
|
|
71
|
+
type PopconfirmTypes = 'primary' | 'success' | 'warning' | 'strong' | 'danger' | 'info';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
返回 [Popconfirm 用法](./popconfirm.md)。
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
2
|
# Popconfirm AI 使用
|
|
3
3
|
|
|
4
|
-
适用版本:x-next@1.
|
|
4
|
+
适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
|
|
5
5
|
|
|
6
|
-
先读 [通用接入](../core.md)。公开导出:`Popconfirm
|
|
6
|
+
先读 [通用接入](../core.md)。公开导出:`Popconfirm`;主要模型:v-model。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./popconfirm-api.md),包含本组件族全部子组件和别名。
|
|
7
7
|
|
|
8
8
|
按需样式:`x-next/style/popconfirm`(包含 base.css、button.css、popconfirm.css、space.css、trigger.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
|
|
9
9
|
|
|
10
|
+
## 已核验行为与示例
|
|
11
|
+
|
|
10
12
|
[组件文档与 live demo](https://x-next.yjmf.com/components/popconfirm)。普通布尔 `v-model` 控制显示,`defaultVisible=false`、`type='danger'`、`position='top'`、`width=150`,点击默认插槽触发。`content` / `icon` 插槽可自定义确认内容;按钮文字用 `okText` / `cancelText`。
|
|
11
13
|
|
|
12
14
|
`ok(event)` / `cancel(event)` 返回 `Event`,`change(visible)` 返回布尔值。`onBeforeOk` / `onBeforeCancel` 支持布尔、void 或 Promise,返回 `false` 可阻止关闭;异步钩子可自动等待,普通 `ok` 监听器不会自动阻止关闭。
|
|
@@ -30,4 +32,230 @@ function cancel(_event: Event) { feedback.value = '已取消删除'; }
|
|
|
30
32
|
</template>
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
## 场景用法
|
|
36
|
+
|
|
37
|
+
以下示例从本地 `src/docs/components/popconfirm.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./popconfirm-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
|
|
38
|
+
|
|
39
|
+
### 用途与选型
|
|
40
|
+
|
|
41
|
+
用于在按钮或链接旁边完成低成本二次确认。
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### 何时使用
|
|
45
|
+
|
|
46
|
+
- 操作会产生删除、提交、发布等不可直接撤销的结果。
|
|
47
|
+
- 不需要打断整页流程,只需要在触发元素附近让用户二次确认。
|
|
48
|
+
- 确认内容较短,适合在小型气泡中展示。
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### 基础用法
|
|
52
|
+
|
|
53
|
+
```vue
|
|
54
|
+
<script setup lang="ts">
|
|
55
|
+
import 'x-next/style.css';
|
|
56
|
+
import { Popconfirm, Button } from 'x-next';
|
|
57
|
+
const handleOk = (event: Event) => {
|
|
58
|
+
console.log('ok', event);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleCancel = (event: Event) => {
|
|
62
|
+
console.log('cancel', event);
|
|
63
|
+
};
|
|
64
|
+
</script>
|
|
65
|
+
<template>
|
|
66
|
+
<Popconfirm content="确认删除这条记录?" @ok="handleOk" @cancel="handleCancel">
|
|
67
|
+
<Button status="danger">删除</Button>
|
|
68
|
+
</Popconfirm>
|
|
69
|
+
</template>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 类型
|
|
73
|
+
|
|
74
|
+
```vue
|
|
75
|
+
<script setup lang="ts">
|
|
76
|
+
import 'x-next/style.css';
|
|
77
|
+
import { Popconfirm, Button } from 'x-next';
|
|
78
|
+
|
|
79
|
+
</script>
|
|
80
|
+
<template>
|
|
81
|
+
<div class="demo-inline-group">
|
|
82
|
+
<Popconfirm type="danger" content="危险操作确认?">
|
|
83
|
+
<Button status="danger">Danger</Button>
|
|
84
|
+
</Popconfirm>
|
|
85
|
+
<Popconfirm type="warning" content="继续执行风险操作?">
|
|
86
|
+
<Button status="warning">Warning</Button>
|
|
87
|
+
</Popconfirm>
|
|
88
|
+
<Popconfirm type="success" content="确认完成任务?">
|
|
89
|
+
<Button status="success">Success</Button>
|
|
90
|
+
</Popconfirm>
|
|
91
|
+
</div>
|
|
92
|
+
</template>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 位置
|
|
96
|
+
|
|
97
|
+
```vue
|
|
98
|
+
<script setup lang="ts">
|
|
99
|
+
import 'x-next/style.css';
|
|
100
|
+
import { Popconfirm, Button } from 'x-next';
|
|
101
|
+
|
|
102
|
+
</script>
|
|
103
|
+
<template>
|
|
104
|
+
<div class="demo-inline-group">
|
|
105
|
+
<Popconfirm position="top" content="上方弹出">
|
|
106
|
+
<Button>Top</Button>
|
|
107
|
+
</Popconfirm>
|
|
108
|
+
<Popconfirm position="bottom" content="下方弹出">
|
|
109
|
+
<Button>Bottom</Button>
|
|
110
|
+
</Popconfirm>
|
|
111
|
+
<Popconfirm position="left" content="左侧弹出">
|
|
112
|
+
<Button>Left</Button>
|
|
113
|
+
</Popconfirm>
|
|
114
|
+
<Popconfirm position="right" content="右侧弹出">
|
|
115
|
+
<Button>Right</Button>
|
|
116
|
+
</Popconfirm>
|
|
117
|
+
</div>
|
|
118
|
+
</template>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 受控显示
|
|
122
|
+
|
|
123
|
+
```vue
|
|
124
|
+
<script setup lang="ts">
|
|
125
|
+
import 'x-next/style.css';
|
|
126
|
+
import { Space, Popconfirm, Button } from 'x-next';
|
|
127
|
+
import { ref } from 'vue';
|
|
128
|
+
|
|
129
|
+
const visible = ref(false);
|
|
130
|
+
</script>
|
|
131
|
+
<template>
|
|
132
|
+
<Space>
|
|
133
|
+
<Popconfirm v-model="visible" content="确认提交当前表单?" position="bottom">
|
|
134
|
+
<Button type="primary">提交</Button>
|
|
135
|
+
</Popconfirm>
|
|
136
|
+
<Button @click="visible = true">外部打开</Button>
|
|
137
|
+
<Button @click="visible = false">外部关闭</Button>
|
|
138
|
+
</Space>
|
|
139
|
+
</template>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 默认显示
|
|
143
|
+
|
|
144
|
+
```vue
|
|
145
|
+
<script setup lang="ts">
|
|
146
|
+
import 'x-next/style.css';
|
|
147
|
+
import { Popconfirm, Button } from 'x-next';
|
|
148
|
+
|
|
149
|
+
</script>
|
|
150
|
+
<template>
|
|
151
|
+
<Popconfirm default-visible content="默认打开,点击取消或确认会关闭">
|
|
152
|
+
<Button>默认打开</Button>
|
|
153
|
+
</Popconfirm>
|
|
154
|
+
</template>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 异步拦截
|
|
158
|
+
|
|
159
|
+
```vue
|
|
160
|
+
<script setup lang="ts">
|
|
161
|
+
import 'x-next/style.css';
|
|
162
|
+
import { Popconfirm, Button } from 'x-next';
|
|
163
|
+
const beforeOk = () => {
|
|
164
|
+
return new Promise<boolean>((resolve) => {
|
|
165
|
+
window.setTimeout(() => resolve(true), 1000);
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const handleOk = () => {
|
|
170
|
+
console.log('confirmed');
|
|
171
|
+
};
|
|
172
|
+
</script>
|
|
173
|
+
<template>
|
|
174
|
+
<Popconfirm content="1 秒后完成确认" :on-before-ok="beforeOk" @ok="handleOk">
|
|
175
|
+
<Button type="primary">异步确认</Button>
|
|
176
|
+
</Popconfirm>
|
|
177
|
+
</template>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### 按钮状态
|
|
181
|
+
|
|
182
|
+
```vue
|
|
183
|
+
<script setup lang="ts">
|
|
184
|
+
import 'x-next/style.css';
|
|
185
|
+
import { Space, Popconfirm, Button } from 'x-next';
|
|
186
|
+
import { ref } from 'vue';
|
|
187
|
+
|
|
188
|
+
const visible = ref(false);
|
|
189
|
+
const saving = ref(false);
|
|
190
|
+
|
|
191
|
+
const handleOk = () => {
|
|
192
|
+
visible.value = false;
|
|
193
|
+
};
|
|
194
|
+
</script>
|
|
195
|
+
<template>
|
|
196
|
+
<Space>
|
|
197
|
+
<Popconfirm
|
|
198
|
+
v-model="visible"
|
|
199
|
+
content="确认按钮 loading 可由外部状态控制"
|
|
200
|
+
ok-text="保存"
|
|
201
|
+
:ok-loading="saving"
|
|
202
|
+
:ok-button-props="{ status: 'success' }"
|
|
203
|
+
:cancel-button-props="{ type: 'text' }"
|
|
204
|
+
@ok="handleOk"
|
|
205
|
+
>
|
|
206
|
+
<Button>按钮 Props</Button>
|
|
207
|
+
</Popconfirm>
|
|
208
|
+
<Button @click="saving = !saving">
|
|
209
|
+
{{ saving ? '关闭 loading' : '开启 loading' }}
|
|
210
|
+
</Button>
|
|
211
|
+
</Space>
|
|
212
|
+
</template>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### 自定义内容
|
|
216
|
+
|
|
217
|
+
```vue
|
|
218
|
+
<script setup lang="ts">
|
|
219
|
+
import 'x-next/style.css';
|
|
220
|
+
import { Popconfirm, Button } from 'x-next';
|
|
221
|
+
|
|
222
|
+
</script>
|
|
223
|
+
<template>
|
|
224
|
+
<Popconfirm width="240" ok-text="归档" cancel-text="取消">
|
|
225
|
+
<Button>归档项目</Button>
|
|
226
|
+
<template #icon>
|
|
227
|
+
<span class="demo-popconfirm-icon">!</span>
|
|
228
|
+
</template>
|
|
229
|
+
<template #content>
|
|
230
|
+
<div class="demo-popconfirm-content">
|
|
231
|
+
<strong>归档后项目将移入历史列表</strong>
|
|
232
|
+
<span>团队成员仍可在历史项目中查看。</span>
|
|
233
|
+
</div>
|
|
234
|
+
</template>
|
|
235
|
+
</Popconfirm>
|
|
236
|
+
</template>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 禁用状态
|
|
240
|
+
|
|
241
|
+
```vue
|
|
242
|
+
<script setup lang="ts">
|
|
243
|
+
import 'x-next/style.css';
|
|
244
|
+
import { Popconfirm, Button } from 'x-next';
|
|
245
|
+
|
|
246
|
+
</script>
|
|
247
|
+
<template>
|
|
248
|
+
<Popconfirm disabled content="禁用后不会弹出">
|
|
249
|
+
<Button disabled>禁用触发</Button>
|
|
250
|
+
</Popconfirm>
|
|
251
|
+
</template>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### 已知限制
|
|
255
|
+
|
|
256
|
+
- Popconfirm 现在基于 `Trigger` 实现,滚动更新、外部点击关闭和箭头定位遵循 Trigger 当前行为。
|
|
257
|
+
- Esc 关闭目前在焦点位于弹层内时生效,触发元素仍依赖原生按钮键盘行为。
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
返回 [AI 索引](../index.md)。先查本页与 [本地 API](./popconfirm-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
|
+
# Popover 完整公开 API
|
|
3
|
+
|
|
4
|
+
适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
|
|
5
|
+
|
|
6
|
+
从同版本构建的公开声明、运行时 props/emits 和显式 expose 生成。运行时导入始终使用 `x-next`,声明路径仅作定位。插槽类型未细化时,具体槽名与作用域见本地用法示例。
|
|
7
|
+
|
|
8
|
+
## Popover API
|
|
9
|
+
|
|
10
|
+
公开声明:`dist/components/popover/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")[] | 否 | "click" |
|
|
19
|
+
| position | 弹出位置 | undefined | "top" | "bottom" | "right" | "left" | "tl" | "tr" | "bl" | "br" | "lt" | "rt" | "lb" | "rb" | 否 | "bottom" |
|
|
20
|
+
| title | 标题内容 | undefined | string | number | 否 | 未声明 |
|
|
21
|
+
| content | 正文内容 | undefined | string | number | 否 | 未声明 |
|
|
22
|
+
| disabled | 是否禁用触发 | undefined | false | true | 否 | false |
|
|
23
|
+
| popupOffset | 弹出层与触发元素的距离 | undefined | number | 否 | 8 |
|
|
24
|
+
| 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; } | 否 | 未声明 |
|
|
25
|
+
| showArrow | 是否显示箭头 | undefined | false | true | 否 | false |
|
|
26
|
+
| alignPoint | 是否跟随鼠标点定位,常用于右键菜单 | undefined | false | true | 否 | false |
|
|
27
|
+
| popupHoverStay | hover 触发时移入浮层是否保持显示 | undefined | false | true | 否 | true |
|
|
28
|
+
| blurToClose | focus 触发时失焦是否关闭 | undefined | false | true | 否 | true |
|
|
29
|
+
| clickToClose | 点击触发器时是否允许关闭 | undefined | false | true | 否 | true |
|
|
30
|
+
| clickOutsideToClose | 点击外部区域是否关闭 | undefined | false | true | 否 | true |
|
|
31
|
+
| unmountOnClose | 关闭后是否卸载浮层节点 | undefined | false | true | 否 | true |
|
|
32
|
+
| contentClass | 弹出内容类名 | undefined | string | { [x: string]: boolean; } | (string | Record<string, boolean>)[] | 否 | 未声明 |
|
|
33
|
+
| contentStyle | 弹出内容样式 | undefined | CSSProperties | 否 | 未声明 |
|
|
34
|
+
| arrowClass | 箭头类名 | undefined | string | { [x: string]: boolean; } | (string | Record<string, boolean>)[] | 否 | 未声明 |
|
|
35
|
+
| arrowStyle | 箭头样式 | undefined | CSSProperties | 否 | 未声明 |
|
|
36
|
+
| popupStyle | 弹出层定位节点样式 | undefined | CSSProperties | 否 | 未声明 |
|
|
37
|
+
| animationName | 动画名称 | undefined | string | 否 | "x-zoom-in-fade-out" |
|
|
38
|
+
| duration | 动画时长 | undefined | number | { enter: number; leave: number; } | 否 | 未声明 |
|
|
39
|
+
| mouseEnterDelay | mouseenter 延迟触发时间,单位毫秒 | undefined | number | 否 | 100 |
|
|
40
|
+
| mouseLeaveDelay | mouseleave 延迟关闭时间,单位毫秒 | undefined | number | 否 | 100 |
|
|
41
|
+
| focusDelay | focus 延迟触发时间,单位毫秒 | undefined | number | 否 | 0 |
|
|
42
|
+
| autoFitPopupWidth | 是否将浮层宽度设为触发器宽度 | undefined | false | true | 否 | false |
|
|
43
|
+
| autoFitPopupMinWidth | 是否将浮层最小宽度设为触发器宽度 | undefined | false | true | 否 | false |
|
|
44
|
+
| autoFixPosition | 触发器尺寸变化时是否重新计算位置 | undefined | false | true | 否 | true |
|
|
45
|
+
| popupContainer | 弹出层挂载容器 | undefined | string | HTMLElement | 否 | 未声明 |
|
|
46
|
+
| updateAtScroll | 容器滚动时是否更新浮层位置 | undefined | false | true | 否 | false |
|
|
47
|
+
| autoFitPosition | 是否自动调整位置以适应视口 | undefined | false | true | 否 | true |
|
|
48
|
+
| renderToBody | 是否挂载到 body 体系下 | undefined | false | true | 否 | true |
|
|
49
|
+
| preventFocus | 是否阻止浮层内元素点击时获得焦点 | undefined | false | true | 否 | false |
|
|
50
|
+
| scrollToClose | 滚动时是否关闭浮层 | undefined | false | true | 否 | false |
|
|
51
|
+
| scrollToCloseDistance | 滚动关闭阈值 | undefined | number | 否 | 0 |
|
|
52
|
+
|
|
53
|
+
### Events
|
|
54
|
+
|
|
55
|
+
| 事件 | 用途 | 监听器签名(即事件参数) |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| update:popupVisible | 显隐状态更新时触发 | undefined | (visible: boolean) => any |
|
|
58
|
+
| popupVisibleChange | 显隐状态变化时触发 | undefined | (visible: boolean) => any |
|
|
59
|
+
| show | 显示动画结束后触发 | undefined | () => any |
|
|
60
|
+
| hide | 隐藏动画结束后触发 | undefined | () => any |
|
|
61
|
+
|
|
62
|
+
### Slots
|
|
63
|
+
|
|
64
|
+
| 名称 | 用途 | 公开类型 |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| default | 触发元素 | any |
|
|
67
|
+
| title | 标题内容 | any |
|
|
68
|
+
| content | 正文内容 | any |
|
|
69
|
+
|
|
70
|
+
### 实例方法
|
|
71
|
+
|
|
72
|
+
没有检索到显式 expose 或 Options API methods 的公开方法;不把 setup 内部函数当成稳定实例 API。
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
返回 [Popover 用法](./popover.md)。
|