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.
Files changed (226) hide show
  1. package/AI_CODING.md +6 -5
  2. package/AI_USAGE/catalog.md +106 -105
  3. package/AI_USAGE/components/alert-api.md +48 -0
  4. package/AI_USAGE/components/alert.md +222 -3
  5. package/AI_USAGE/components/bar-chart-api.md +177 -0
  6. package/AI_USAGE/components/bar-chart.md +297 -3
  7. package/AI_USAGE/components/boxicons.md +147 -0
  8. package/AI_USAGE/components/button-api.md +144 -0
  9. package/AI_USAGE/components/button.md +447 -3
  10. package/AI_USAGE/components/charts.md +81 -0
  11. package/AI_USAGE/components/checkbox-api.md +145 -0
  12. package/AI_USAGE/components/checkbox.md +365 -3
  13. package/AI_USAGE/components/color-picker-api.md +52 -0
  14. package/AI_USAGE/components/color-picker.md +211 -3
  15. package/AI_USAGE/components/config-provider-api.md +38 -0
  16. package/AI_USAGE/components/config-provider.md +250 -3
  17. package/AI_USAGE/components/date-picker-api.md +1114 -0
  18. package/AI_USAGE/components/date-picker.md +378 -3
  19. package/AI_USAGE/components/dialog-api.md +142 -0
  20. package/AI_USAGE/components/dialog.md +284 -3
  21. package/AI_USAGE/components/draggable-api.md +146 -0
  22. package/AI_USAGE/components/draggable.md +259 -0
  23. package/AI_USAGE/components/drawer-api.md +78 -0
  24. package/AI_USAGE/components/drawer.md +227 -0
  25. package/AI_USAGE/components/dropdown-api.md +529 -0
  26. package/AI_USAGE/components/dropdown.md +392 -3
  27. package/AI_USAGE/components/empty-api.md +36 -0
  28. package/AI_USAGE/components/empty.md +227 -3
  29. package/AI_USAGE/components/finicon.md +88 -0
  30. package/AI_USAGE/components/form-api.md +524 -0
  31. package/AI_USAGE/components/form.md +454 -0
  32. package/AI_USAGE/components/grid-api.md +527 -0
  33. package/AI_USAGE/components/grid.md +224 -0
  34. package/AI_USAGE/components/heatmap-api.md +122 -0
  35. package/AI_USAGE/components/heatmap.md +220 -0
  36. package/AI_USAGE/components/icon-api.md +4707 -0
  37. package/AI_USAGE/components/icon.md +257 -0
  38. package/AI_USAGE/components/image-api.md +440 -0
  39. package/AI_USAGE/components/image.md +465 -0
  40. package/AI_USAGE/components/input-api.md +184 -0
  41. package/AI_USAGE/components/input-number-api.md +66 -0
  42. package/AI_USAGE/components/input-number.md +294 -0
  43. package/AI_USAGE/components/input-tag-api.md +114 -0
  44. package/AI_USAGE/components/input-tag.md +482 -0
  45. package/AI_USAGE/components/input.md +293 -3
  46. package/AI_USAGE/components/layout-api.md +147 -0
  47. package/AI_USAGE/components/layout.md +230 -0
  48. package/AI_USAGE/components/line-chart-api.md +197 -0
  49. package/AI_USAGE/components/line-chart.md +279 -3
  50. package/AI_USAGE/components/link-api.md +42 -0
  51. package/AI_USAGE/components/link.md +197 -0
  52. package/AI_USAGE/components/menu-api.md +516 -0
  53. package/AI_USAGE/components/menu.md +268 -0
  54. package/AI_USAGE/components/message-api.md +215 -0
  55. package/AI_USAGE/components/message-box-api.md +108 -0
  56. package/AI_USAGE/components/message-box.md +268 -3
  57. package/AI_USAGE/components/message.md +231 -3
  58. package/AI_USAGE/components/network-api.md +91 -0
  59. package/AI_USAGE/components/network.md +378 -0
  60. package/AI_USAGE/components/notification-api.md +236 -0
  61. package/AI_USAGE/components/notification.md +275 -3
  62. package/AI_USAGE/components/pagination-api.md +62 -0
  63. package/AI_USAGE/components/pagination.md +386 -5
  64. package/AI_USAGE/components/pie-chart-api.md +109 -0
  65. package/AI_USAGE/components/pie-chart.md +245 -3
  66. package/AI_USAGE/components/popconfirm-api.md +75 -0
  67. package/AI_USAGE/components/popconfirm.md +231 -3
  68. package/AI_USAGE/components/popover-api.md +75 -0
  69. package/AI_USAGE/components/popover.md +208 -3
  70. package/AI_USAGE/components/popup-api.md +75 -0
  71. package/AI_USAGE/components/popup.md +52 -0
  72. package/AI_USAGE/components/progress-api.md +44 -0
  73. package/AI_USAGE/components/progress.md +248 -3
  74. package/AI_USAGE/components/radio-api.md +165 -0
  75. package/AI_USAGE/components/radio.md +259 -3
  76. package/AI_USAGE/components/rate-api.md +54 -0
  77. package/AI_USAGE/components/rate.md +233 -3
  78. package/AI_USAGE/components/resize-box-api.md +56 -0
  79. package/AI_USAGE/components/resize-box.md +231 -0
  80. package/AI_USAGE/components/scrollbar-api.md +77 -0
  81. package/AI_USAGE/components/scrollbar.md +218 -0
  82. package/AI_USAGE/components/select-api.md +758 -0
  83. package/AI_USAGE/components/select.md +640 -3
  84. package/AI_USAGE/components/skeleton-api.md +85 -0
  85. package/AI_USAGE/components/skeleton.md +150 -0
  86. package/AI_USAGE/components/slider-api.md +51 -0
  87. package/AI_USAGE/components/slider.md +233 -3
  88. package/AI_USAGE/components/space-api.md +38 -0
  89. package/AI_USAGE/components/space.md +145 -0
  90. package/AI_USAGE/components/spin-api.md +43 -0
  91. package/AI_USAGE/components/spin.md +205 -0
  92. package/AI_USAGE/components/steps-api.md +111 -0
  93. package/AI_USAGE/components/steps.md +201 -3
  94. package/AI_USAGE/components/switch-api.md +58 -0
  95. package/AI_USAGE/components/switch.md +290 -3
  96. package/AI_USAGE/components/table-api.md +2919 -0
  97. package/AI_USAGE/components/table.md +1414 -0
  98. package/AI_USAGE/components/tabs-api.md +135 -0
  99. package/AI_USAGE/components/tabs.md +308 -3
  100. package/AI_USAGE/components/tag-api.md +124 -0
  101. package/AI_USAGE/components/tag.md +292 -0
  102. package/AI_USAGE/components/textarea-api.md +55 -0
  103. package/AI_USAGE/components/textarea.md +326 -3
  104. package/AI_USAGE/components/time-picker-api.md +137 -0
  105. package/AI_USAGE/components/time-picker.md +271 -3
  106. package/AI_USAGE/components/time-range-selector-api.md +44 -0
  107. package/AI_USAGE/components/time-range-selector.md +355 -0
  108. package/AI_USAGE/components/timeline-api.md +93 -0
  109. package/AI_USAGE/components/timeline.md +312 -0
  110. package/AI_USAGE/components/tooltip-api.md +77 -0
  111. package/AI_USAGE/components/tooltip.md +182 -0
  112. package/AI_USAGE/components/trend-chart-api.md +119 -0
  113. package/AI_USAGE/components/trend-chart.md +335 -0
  114. package/AI_USAGE/components/trigger-api.md +124 -0
  115. package/AI_USAGE/components/trigger.md +185 -0
  116. package/AI_USAGE/components/upload-api.md +200 -0
  117. package/AI_USAGE/components/upload.md +711 -3
  118. package/AI_USAGE/components/watermark-api.md +87 -0
  119. package/AI_USAGE/components/watermark.md +200 -0
  120. package/AI_USAGE/core.md +1 -1
  121. package/AI_USAGE/index.md +35 -7
  122. package/AI_USAGE/recipes/form-on-demand.md +1 -1
  123. package/AI_USAGE.md +33657 -7
  124. package/CHANGELOG.md +40 -0
  125. package/dist/_utils/inherit-component-type.d.ts +11 -0
  126. package/dist/components/date-picker/index.d.ts +420 -5
  127. package/dist/components/form-input/index.d.ts +617 -2
  128. package/dist/components/layout/index.d.ts +689 -1
  129. package/dist/components/menu/index.d.ts +786 -1
  130. package/dist/components/network/Network.vue.d.ts +7 -3
  131. package/dist/components/network/index.d.ts +10 -2
  132. package/dist/components/network/props.d.ts +5 -0
  133. package/dist/components/network/utils.d.ts +3 -3
  134. package/dist/components/pagination/page-item-ellipsis.vue.d.ts +4 -1
  135. package/dist/components/pagination/page-item-step.vue.d.ts +101 -130
  136. package/dist/components/pagination/page-item.vue.d.ts +1 -0
  137. package/dist/components/pagination/page-jumper.vue.d.ts +1 -1
  138. package/dist/components/pagination/page-options.vue.d.ts +6 -4
  139. package/dist/components/pagination/utils.d.ts +3 -0
  140. package/dist/components/time-range-selector/index.d.ts +6 -6
  141. package/dist/es/_container/resize-observer-v2.js +1 -1
  142. package/dist/es/_container/resize-observer.js +1 -1
  143. package/dist/es/_hooks/use-resize-observer.js +1 -1
  144. package/dist/es/_styles/palette-aliases.js +4 -4
  145. package/dist/es/_utils/inherit-component-type.js +6 -0
  146. package/dist/es/_virtual/advancedFormat.js +1 -1
  147. package/dist/es/_virtual/customParseFormat.js +1 -1
  148. package/dist/es/_virtual/dayjs.min.js +1 -1
  149. package/dist/es/_virtual/isBetween.js +1 -1
  150. package/dist/es/_virtual/quarterOfYear.js +1 -1
  151. package/dist/es/_virtual/weekOfYear.js +1 -1
  152. package/dist/es/_virtual/weekYear.js +1 -1
  153. package/dist/es/_virtual/zh-cn.js +1 -1
  154. package/dist/es/components/button/Button.js +53 -42
  155. package/dist/es/components/date-picker/index.js +18 -17
  156. package/dist/es/components/draggable/useDraggable.js +1 -1
  157. package/dist/es/components/form/Form.vue2.js +1 -1
  158. package/dist/es/components/form/FormItem.vue2.js +1 -1
  159. package/dist/es/components/form-input/index.js +12 -11
  160. package/dist/es/components/form-input-number/InputNumber.js +1 -1
  161. package/dist/es/components/form-slider/Slider.vue2.js +1 -1
  162. package/dist/es/components/form-slider/slider-ticks.vue2.js +1 -1
  163. package/dist/es/components/form-slider/utils.js +1 -1
  164. package/dist/es/components/layout/index.js +10 -9
  165. package/dist/es/components/menu/MenuItem.js +1 -1
  166. package/dist/es/components/menu/hooks/use-level.js +5 -5
  167. package/dist/es/components/menu/index.js +13 -10
  168. package/dist/es/components/menu/overflow-wrap.js +1 -1
  169. package/dist/es/components/network/Network.vue.js +17 -12
  170. package/dist/es/components/network/Network.vue2.js +78 -70
  171. package/dist/es/components/network/utils.js +112 -71
  172. package/dist/es/components/pagination/Pagination.js +132 -123
  173. package/dist/es/components/pagination/page-item-ellipsis.vue.js +10 -10
  174. package/dist/es/components/pagination/page-item-ellipsis.vue2.js +24 -19
  175. package/dist/es/components/pagination/page-item-step.vue.js +14 -11
  176. package/dist/es/components/pagination/page-item-step.vue2.js +20 -22
  177. package/dist/es/components/pagination/page-item.vue.js +10 -9
  178. package/dist/es/components/pagination/page-item.vue2.js +24 -19
  179. package/dist/es/components/pagination/page-jumper.vue2.js +23 -23
  180. package/dist/es/components/pagination/page-options.vue.js +15 -10
  181. package/dist/es/components/pagination/page-options.vue2.js +21 -17
  182. package/dist/es/components/pagination/utils.js +4 -2
  183. package/dist/es/components/progress/circle.vue2.js +1 -1
  184. package/dist/es/components/progress/line.vue2.js +1 -1
  185. package/dist/es/components/progress/steps.vue2.js +1 -1
  186. package/dist/es/components/rate/Rate.js +1 -1
  187. package/dist/es/components/virtual-list-v2/virtual-list-item.js +1 -1
  188. package/dist/es/locale/en-US.js +2 -0
  189. package/dist/es/locale/zh-CN.js +2 -0
  190. 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
  191. 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
  192. 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
  193. 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
  194. 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
  195. 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
  196. 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
  197. 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
  198. package/dist/es/style.css +1 -1
  199. package/dist/index.cjs +3 -3
  200. package/dist/index.umd.js +3 -3
  201. package/dist/locale/interface.d.ts +3 -0
  202. package/dist/style/base.css +1 -1
  203. package/dist/style/button.css +1 -1
  204. package/dist/style/form-select.css +1 -1
  205. package/dist/style/network.css +1 -1
  206. package/dist/style/pagination.css +1 -1
  207. package/dist/style/table.css +1 -1
  208. package/dist/style.css +1 -1
  209. package/package.json +10 -5
  210. /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
  211. /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
  212. /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
  213. /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
  214. /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
  215. /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
  216. /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
  217. /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
  218. /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
  219. /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
  220. /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
  221. /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
  222. /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
  223. /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
  224. /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
  225. /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
  226. /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,378 @@
1
+ <!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
2
+ # Network AI 使用
3
+
4
+ 适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
5
+
6
+ 先读 [通用接入](../core.md)。公开导出:`Network`;主要模型:无。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./network-api.md),包含本组件族全部子组件和别名。
7
+
8
+ 按需样式:`x-next/style/network`(包含 base.css、network.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
9
+
10
+ ## 场景用法
11
+
12
+ 以下示例从本地 `src/docs/components/network.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./network-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
13
+
14
+ ### 用途与选型
15
+
16
+ 用于展示浏览器连接提示、离线状态与指定资源的主动探测结果。
17
+
18
+
19
+ ### 何时使用
20
+
21
+ - 在提交、同步或长时间编辑场景提供轻量网络提示。
22
+ - 用业务健康检查地址提示服务可达性,或通过受控状态展示业务已经检测到的质量。
23
+ - 需要自定义图标、文字和重试按钮时使用默认插槽。
24
+
25
+
26
+ ### 基础用法
27
+
28
+ 默认仅展示信号条。`good / medium / poor` 用激活条数和颜色表达质量,`offline / unknown` 均为零激活条;需要准确文字时使用提示或默认插槽。
29
+
30
+ ```vue
31
+ <script setup lang="ts">
32
+ import 'x-next/style.css';
33
+ import { Network } from 'x-next';
34
+
35
+ </script>
36
+ <template>
37
+ <div class="example-box">
38
+ <Network />
39
+ <Network status="good" show-tooltip />
40
+ <Network status="medium" show-tooltip />
41
+ <Network status="poor" show-tooltip />
42
+ <Network status="offline" show-tooltip />
43
+ <Network status="unknown" show-tooltip />
44
+ </div>
45
+ </template>
46
+ ```
47
+
48
+ ### 尺寸
49
+
50
+ mini / small 为 3 条,medium 为 4 条,large 为 5 条。尺寸只影响展示,不影响探测策略。
51
+
52
+ ```vue
53
+ <script setup lang="ts">
54
+ import 'x-next/style.css';
55
+ import { Network } from 'x-next';
56
+
57
+ </script>
58
+ <template>
59
+ <div class="example-box">
60
+ <Network size="mini" status="good" />
61
+ <Network size="small" status="good" />
62
+ <Network size="medium" status="good" />
63
+ <Network size="large" status="good" />
64
+ </div>
65
+ </template>
66
+ ```
67
+
68
+ ### 受控状态与自动切换
69
+
70
+ 传入 `status` 后只展示,不启动网络监听、轮询或主动请求,也不因 prop 变化发送事件。改回 `undefined` 会重新启动自动检测,并发送该轮的初始 `change`,不会把受控值当成浏览器连接跃迁。
71
+
72
+ ```vue
73
+ <script setup lang="ts">
74
+ import 'x-next/style.css';
75
+ import { Network, Space, Button } from 'x-next';
76
+ import { ref } from 'vue';
77
+ import type { NetworkQuality } from 'x-next';
78
+ const controlledStatus = ref<NetworkQuality | undefined>('medium');
79
+ </script>
80
+ <template>
81
+ <div class="example-box example-box-column">
82
+ <Network :status="controlledStatus" show-tooltip />
83
+ <Space>
84
+ <Button size="small" @click="controlledStatus = 'good'">良好</Button>
85
+ <Button size="small" @click="controlledStatus = 'medium'">一般</Button>
86
+ <Button size="small" @click="controlledStatus = 'poor'">较差</Button>
87
+ <Button size="small" @click="controlledStatus = 'offline'">离线</Button>
88
+ <Button size="small" @click="controlledStatus = 'unknown'">未知</Button>
89
+ <Button size="small" @click="controlledStatus = undefined">自动检测</Button>
90
+ </Space>
91
+ <span>{{ controlledStatus === undefined ? '浏览器自动模式' : '受控展示:' + controlledStatus }}</span>
92
+ </div>
93
+ </template>
94
+ ```
95
+
96
+ ### 状态颜色
97
+
98
+ `statusColors` 优先于兼容入口 `signalStrengthColor`;兼容入口只设置 good / poor。offline / unknown 的零激活条也可配置颜色,其他状态的未激活条使用默认中性色。
99
+
100
+ ```vue
101
+ <script setup lang="ts">
102
+ import 'x-next/style.css';
103
+ import { Network } from 'x-next';
104
+
105
+ </script>
106
+ <template>
107
+ <div class="example-box">
108
+ <Network status="good" :status-colors="{ good: '#0f766e' }" />
109
+ <Network status="medium" :status-colors="{ medium: '#b45309' }" />
110
+ <Network status="poor" :status-colors="{ poor: '#dc2626' }" />
111
+ <Network status="offline" :status-colors="{ offline: '#64748b' }" show-tooltip />
112
+ <Network status="unknown" :status-colors="{ unknown: '#7c3aed' }" show-tooltip />
113
+ <Network status="good" :signal-strength-color="['#2563eb', '#ea580c']" />
114
+ <Network status="poor" :signal-strength-color="['#2563eb', '#ea580c']" />
115
+ </div>
116
+ </template>
117
+ ```
118
+
119
+ ### 无障碍与悬浮提示
120
+
121
+ 默认图标具有 `role="status"`、`aria-live="polite"` 和随状态更新的隐藏文本,指标数字不进入默认播报。`ariaLive="off"` 可用于重复的装饰提示。`showTooltip` 使用原生 title,不增加 Tab 停靠点;需要触屏或键盘提示时组合 Tooltip 或文字插槽。自定义插槽应提供自己的状态文字和操作名称。
122
+
123
+ 在启用严格模板类型检查的 SFC 中,使用已声明的 `ariaLabel / ariaLive` 组件 props,组件会输出对应原生 ARIA 属性。
124
+
125
+ ```vue
126
+ <script setup lang="ts">
127
+ import 'x-next/style.css';
128
+ import { Network } from 'x-next';
129
+
130
+ </script>
131
+ <template>
132
+ <div class="example-box">
133
+ <Network status="medium" ariaLabel="当前网络略慢" />
134
+ <Network
135
+ status="poor"
136
+ show-tooltip
137
+ ariaLabel="当前网络较差,请稍后提交"
138
+ ariaLive="assertive"
139
+ />
140
+ <Network status="good" ariaLive="off" />
141
+ </div>
142
+ </template>
143
+ ```
144
+
145
+ ### 主动探测和事件
146
+
147
+ 首次自动检测发送 `change`;随后比较全部状态字段(除时间戳)再决定是否发送。每次主动探测完成均发送 `probe`,所以同一轮可能出现两条不同事件日志。`online / offline` 仅表示浏览器自动模式下的连接跃迁,首次已离线不会额外发送 `offline`。可在开发者工具中切换 Offline 验证这两个事件;文档按钮只发起请求,不模拟设备断网。
148
+
149
+ 不传 `ping` 时读取浏览器连接提示并监听在线、离线与连接变化;传入后在挂载、连接变化、手动刷新及轮询时请求该地址。`interval` 是轮询请求完成后到下一轮的等待时间,多个手动刷新会复用进行中的请求。浏览器状态变化会取消旧轮次,离线状态优先。
150
+
151
+ ```vue
152
+ <script setup lang="ts">
153
+ import 'x-next/style.css';
154
+ import { Network, Button } from 'x-next';
155
+ import { ref } from 'vue';
156
+ import type { NetworkStatus } from 'x-next';
157
+ const eventNetwork = ref<{ refresh: () => Promise<NetworkStatus> }>();
158
+ const eventRefreshing = ref(false);
159
+ const eventLogs = ref<Array<{ id: number; text: string }>>([]);
160
+ let eventSequence = 0;
161
+ const pushNetworkLog = (event: string, status: NetworkStatus) => {
162
+ const latency = status.latency === undefined ? '' : ` / ${status.latency}ms`;
163
+ const reason = status.reason ? ` / ${status.reason}` : '';
164
+ eventLogs.value = [{ id: ++eventSequence, text: `${event}: ${status.quality} / ${status.source}${reason}${latency}` }, ...eventLogs.value].slice(0, 4);
165
+ };
166
+ const refreshEventNetwork = async () => {
167
+ if (!eventNetwork.value || eventRefreshing.value) return;
168
+ eventRefreshing.value = true;
169
+ try { await eventNetwork.value.refresh(); }
170
+ finally { eventRefreshing.value = false; }
171
+ };
172
+ </script>
173
+ <template>
174
+ <div class="example-box example-box-column">
175
+ <Network
176
+ ref="eventNetwork"
177
+ show-metrics
178
+ ping="/logo.svg"
179
+ :interval="8000"
180
+ :timeout="3000"
181
+ @change="pushNetworkLog('change', $event)"
182
+ @probe="pushNetworkLog('probe', $event)"
183
+ @online="pushNetworkLog('online', $event)"
184
+ @offline="pushNetworkLog('offline', $event)"
185
+ />
186
+ <Button size="small" :loading="eventRefreshing" @click="refreshEventNetwork">立即探测</Button>
187
+ <div class="demo-network-log">
188
+ <div v-for="item in eventLogs" :key="item.id">{{ item.text }}</div>
189
+ </div>
190
+ </div>
191
+ </template>
192
+ ```
193
+
194
+ ### 探测失败和超时
195
+
196
+ 此地址用于稳定演示请求失败,正常在线时结果为 `poor / probe-error`。非 2xx 响应为 `http-error`,整个请求(含响应体)超时为 `probe-timeout`;只有浏览器明确离线才显示 offline。演示真实超时需要一个延迟超过 `timeout` 的服务,可在本地健康检查接口验证,本页不依赖外部慢接口。
197
+
198
+ ```vue
199
+ <script setup lang="ts">
200
+ import 'x-next/style.css';
201
+ import { Network, Button } from 'x-next';
202
+ import { ref } from 'vue';
203
+ import type { NetworkStatus } from 'x-next';
204
+ const failureLogs = ref<Array<{ id: number; text: string }>>([]);
205
+ const failureRefreshing = ref(false);
206
+ let failureSequence = 0;
207
+ const pushFailureLog = (status: NetworkStatus) => {
208
+ failureLogs.value = [{ id: ++failureSequence, text: `${status.quality} / ${status.reason || 'probe'}` }, ...failureLogs.value].slice(0, 3);
209
+ };
210
+ const retryFailure = async (refresh: () => Promise<NetworkStatus>) => {
211
+ if (failureRefreshing.value) return;
212
+ failureRefreshing.value = true;
213
+ try { await refresh(); }
214
+ finally { failureRefreshing.value = false; }
215
+ };
216
+ </script>
217
+ <template>
218
+ <div class="example-box example-box-column">
219
+ <Network
220
+ ping="https://probe.invalid/ping"
221
+ show-metrics
222
+ :timeout="1000"
223
+ @probe="pushFailureLog"
224
+ >
225
+ <template #default="{ quality, reason, refresh }">
226
+ <div class="demo-network-card">
227
+ <span>{{ quality }} / {{ reason || '等待探测' }}</span>
228
+ <Button size="small" :loading="failureRefreshing" @click="retryFailure(refresh)">重试探测</Button>
229
+ </div>
230
+ </template>
231
+ </Network>
232
+ <div class="demo-network-log">
233
+ <div v-for="item in failureLogs" :key="item.id">{{ item.text }}</div>
234
+ </div>
235
+ </div>
236
+ </template>
237
+ ```
238
+
239
+ ### 下载估算与尺寸边界
240
+
241
+ `showMetrics` 展示上下两行,例如 `9ms` / `42K/s`。`latency` 是到响应头的耗时,质量分档按该值判断(低于 500ms 为 good,低于 1500ms 为 medium,否则 poor);`downloadSpeed` 用实际响应体字节数除以整个请求耗时估算。这里的 K/s、M/s 分别按 1024 bytes/s、1024² bytes/s 格式化。空响应体或没有速度数据时显示 `--`。
242
+
243
+ 使用同源小资源或允许 CORS 的小型健康检查资源,业务项目需自行提供 `/logo.svg` 或替换地址。请求会读取完整响应体,即使未开启指标也会进行下载估算;避免大文件。该数值不是正在下载的业务任务或整机实时流量。
244
+
245
+ ```vue
246
+ <script setup lang="ts">
247
+ import 'x-next/style.css';
248
+ import { Network } from 'x-next';
249
+
250
+ </script>
251
+ <template>
252
+ <div class="example-box">
253
+ <Network size="mini" show-metrics ping="/logo.svg" />
254
+ <Network size="small" show-metrics ping="/logo.svg" />
255
+ <Network size="medium" show-metrics ping="/logo.svg" />
256
+ <Network size="large" show-metrics ping="/logo.svg" />
257
+ <Network status="unknown" show-metrics show-tooltip />
258
+ </div>
259
+ </template>
260
+ ```
261
+
262
+ ### 自定义展示与刷新
263
+
264
+ 默认插槽完全替换图标和指标。此示例使用自动探测,点击或键盘激活按钮后展示返回状态与完成次数;按钮 loading 是示例业务状态,组件本身没有 loading prop。插槽也提供 `status / online / downloadSpeed / speedSource / source / reason`。
265
+
266
+ ```vue
267
+ <script setup lang="ts">
268
+ import 'x-next/style.css';
269
+ import { Network, Button } from 'x-next';
270
+ import { ref } from 'vue';
271
+ import type { NetworkStatus } from 'x-next';
272
+ const customRefreshing = ref(false);
273
+ const customRefreshCount = ref(0);
274
+ const customResult = ref('等待手动刷新');
275
+ const refreshCustom = async (refresh: () => Promise<NetworkStatus>) => {
276
+ if (customRefreshing.value) return;
277
+ customRefreshing.value = true;
278
+ try {
279
+ const status = await refresh();
280
+ customRefreshCount.value += 1;
281
+ customResult.value = `${status.quality} / ${status.source}`;
282
+ } finally { customRefreshing.value = false; }
283
+ };
284
+ </script>
285
+ <template>
286
+ <div class="example-box example-box-column">
287
+ <Network ping="/logo.svg">
288
+ <template #default="{ quality, latency, refresh }">
289
+ <div class="demo-network-card">
290
+ <strong>网络状态:{{ quality }}</strong>
291
+ <span v-if="latency !== undefined">{{ latency }}ms</span>
292
+ <Button size="small" :loading="customRefreshing" @click="refreshCustom(refresh)">重新检测</Button>
293
+ </div>
294
+ </template>
295
+ </Network>
296
+ <span>手动刷新完成 {{ customRefreshCount }} 次;{{ customResult }}</span>
297
+ </div>
298
+ </template>
299
+ ```
300
+
301
+ ### 受控模式的实例方法
302
+
303
+ `refresh()` 始终返回 `Promise<NetworkStatus>`。受控模式会返回当前归一化状态,并主动发送一次 `change`,不会请求 ping 或发送 probe / online / offline。组件未挂载或卸载后返回快照,不再产生请求和事件。
304
+
305
+ ```vue
306
+ <script setup lang="ts">
307
+ import 'x-next/style.css';
308
+ import { Network, Button } from 'x-next';
309
+ import { ref } from 'vue';
310
+ import type { NetworkStatus } from 'x-next';
311
+ const manualNetwork = ref<{ refresh: () => Promise<NetworkStatus> }>();
312
+ const manualResult = ref('尚未读取');
313
+ const manualChanges = ref(0);
314
+ const readManualSnapshot = async () => {
315
+ if (!manualNetwork.value) return;
316
+ const status = await manualNetwork.value.refresh();
317
+ manualResult.value = `${status.quality} / ${status.source}`;
318
+ };
319
+ </script>
320
+ <template>
321
+ <div class="example-box example-box-column">
322
+ <Network ref="manualNetwork" status="poor" @change="manualChanges += 1" />
323
+ <Button size="small" @click="readManualSnapshot">读取受控状态</Button>
324
+ <span>{{ manualResult }};change 回调 {{ manualChanges }} 次</span>
325
+ </div>
326
+ </template>
327
+ ```
328
+
329
+ ### 根节点属性与样式
330
+
331
+ `class / style / id / title` 和原生监听器透传到根 div,与内部结构类合并。此处原生属性对象仅包含已验证落到根节点的 id/title。`showTooltip` 开启时默认提供状态 title;显式原生 title 可覆盖。CSS 变量可局部调整图标,避免直接依赖内部元素选择器。
332
+
333
+ ```vue
334
+ <script setup lang="ts">
335
+ import 'x-next/style.css';
336
+ import { Network } from 'x-next';
337
+ import type { HTMLAttributes } from 'vue';
338
+ const rootAttrs: Pick<HTMLAttributes, 'id' | 'title'> = {
339
+ id: 'network-root-demo',
340
+ title: '业务自定义标题',
341
+ };
342
+ </script>
343
+ <template>
344
+ <div class="example-box">
345
+ <Network
346
+ v-bind="rootAttrs"
347
+ class="demo-network-indicator"
348
+ status="good"
349
+ :style="{ '--x-network-width': '36px', '--x-network-height': '24px', '--x-network-signal-width': '5px' }"
350
+ />
351
+ </div>
352
+ </template>
353
+ ```
354
+
355
+ ### CSS 变量
356
+
357
+ | 变量 | 用途 |
358
+ | --- | --- |
359
+ | `--x-network-width` / `--x-network-height` | 信号图标宽、高 |
360
+ | `--x-network-signal-width` / `--x-network-gap` | 单条宽度、信号与指标间距 |
361
+ | `--x-network-color-good` / `medium` / `poor` / `offline` / `unknown` | 各状态信号色(完整变量均以 `--x-network-color-` 开头) |
362
+ | `--x-network-color-inactive` | 有信号状态中的未激活条颜色 |
363
+ | `--x-network-text-color` / `--x-network-metrics-font-size` | 指标颜色、字号 |
364
+
365
+
366
+ ### 已知限制
367
+
368
+ - Network Information API 并非所有浏览器都有。完全缺失时在线回退 good;有 connection 但字段不足时回退 unknown(默认文案“检测中”),不代表正在反复请求。effectiveType 是网络估算档位,不是实际蜂窝制式。
369
+ - `navigator.onLine` 只提供浏览器连接线索,good 不能证明互联网或业务服务可达。请求失败时浏览器仍在线,quality 为 poor、online 仍为 true。
370
+ - 每个自动实例独立监听与请求;没有共享采样、抖动阈值、自定义请求或鉴权 headers API。纯展示优先使用受控模式。
371
+ - 下载估算容易受资源大小、缓存层、Service Worker、服务处理耗时等影响;`cache: 'no-cache'` 不能排除所有缓存。没有上传/整机流量统计。
372
+ - onchange 降级时 x-next 实例共享监听并转发已有处理器;如果外部随后直接覆盖该单槽位,旧监听不再接收连接变化,卸载也不会覆盖外部的新处理器。
373
+ - SSR 只渲染占位或受控值,挂载后才创建探测实例。不支持 AbortController 时仍按 timeout 结束组件等待,但宿主中的实际底层请求无法由组件中止。
374
+ - 组件没有打开/关闭、清空、选择、禁用或只读行为;重试按钮及其 loading 状态由业务插槽实现。
375
+
376
+
377
+
378
+ 返回 [AI 索引](../index.md)。先查本页与 [本地 API](./network-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。
@@ -0,0 +1,236 @@
1
+ <!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
2
+ # Notification 完整公开 API
3
+
4
+ 适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
5
+
6
+ 从同版本构建的公开声明、运行时 props/emits 和显式 expose 生成。运行时导入始终使用 `x-next`,声明路径仅作定位。插槽类型未细化时,具体槽名与作用域见本地用法示例。
7
+
8
+ ## Notification API
9
+
10
+ 公开声明:`dist/components/notification/warp.d.ts`。
11
+
12
+ ### 服务调用
13
+
14
+ | 签名 |
15
+ | --- |
16
+ | (options: NotificationParams, appContext?: AppContext): NotificationReturn |
17
+
18
+ ### 服务成员
19
+
20
+ | 名称 | 类型 |
21
+ | --- | --- |
22
+ | info | (options: NotificationParams, appContext?: AppContext) => NotificationReturn |
23
+ | success | (options: NotificationParams, appContext?: AppContext) => NotificationReturn |
24
+ | warning | (options: NotificationParams, appContext?: AppContext) => NotificationReturn |
25
+ | strong | (options: NotificationParams, appContext?: AppContext) => NotificationReturn |
26
+ | error | (options: NotificationParams, appContext?: AppContext) => NotificationReturn |
27
+ | remove | (id: string &#124; number) => void |
28
+ | clear | (position?: NotificationPosition) => void |
29
+ | _context | undefined &#124; null &#124; AppContext |
30
+
31
+ ### 关联类型定义
32
+
33
+ 以下摘自本组件族声明,供查阅嵌套配置;运行时和值类型均以根入口可导出项为准。
34
+
35
+ ```typescript-reference
36
+ declare const types: readonly ["success", "strong", "warning", "error", "info"];
37
+
38
+ type NotificationType = (typeof types)[number];
39
+
40
+ type NotificationContent = string | number | RenderFunction | VNode;
41
+
42
+ interface NotificationOptions {
43
+ id?: string | number;
44
+ title?: NotificationContent;
45
+ message?: NotificationContent;
46
+ content?: NotificationContent;
47
+ type?: NotificationType;
48
+ duration?: number;
49
+ position?: NotificationPosition;
50
+ offset?: number;
51
+ renderTo?: string | HTMLElement;
52
+ showClose?: boolean;
53
+ closable?: boolean;
54
+ showIcon?: boolean;
55
+ icon?: RenderFunction | VNode;
56
+ footer?: RenderFunction | VNode;
57
+ closeIcon?: RenderFunction | VNode;
58
+ popupClass?: string;
59
+ class?: string;
60
+ style?: CSSProperties;
61
+ onClick?: () => void;
62
+ onClose?: (id?: string | number) => void;
63
+ }
64
+
65
+ type NotificationPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
66
+
67
+ type NotificationParams = NotificationOptions | NotificationContent;
68
+
69
+ interface NotificationReturn {
70
+ close(): void;
71
+ }
72
+
73
+ interface NotificationCaller {
74
+ (options: NotificationParams, appContext?: AppContext): NotificationReturn;
75
+ }
76
+
77
+ interface NotificationMethods extends NotificationCaller {
78
+ info(options: NotificationParams, appContext?: AppContext): NotificationReturn;
79
+ success(options: NotificationParams, appContext?: AppContext): NotificationReturn;
80
+ warning(options: NotificationParams, appContext?: AppContext): NotificationReturn;
81
+ strong(options: NotificationParams, appContext?: AppContext): NotificationReturn;
82
+ error(options: NotificationParams, appContext?: AppContext): NotificationReturn;
83
+ remove(id: string | number): void;
84
+ clear(position?: NotificationPosition): void;
85
+ }
86
+
87
+ interface NotificationItem {
88
+ id: string | number;
89
+ title?: NotificationContent;
90
+ message: NotificationContent;
91
+ type: NotificationType;
92
+ duration: number;
93
+ showClose: boolean;
94
+ showIcon: boolean;
95
+ icon?: RenderFunction | VNode;
96
+ footer?: RenderFunction | VNode;
97
+ closeIcon?: RenderFunction | VNode;
98
+ popupClass?: string;
99
+ class?: string;
100
+ style?: CSSProperties;
101
+ offset: number;
102
+ onClick?: () => void;
103
+ onClose?: (id?: string | number) => void;
104
+ resetOnUpdate?: boolean;
105
+ }
106
+
107
+ type NotificationProps = ExtractPropTypes<typeof notificationProps>;
108
+
109
+ type NotificationApi = NotificationMethods & {
110
+ _context?: AppContext | null;
111
+ install?: (app: App) => void;
112
+ };
113
+ ```
114
+
115
+
116
+ ## NotificationComponent API
117
+
118
+ 公开声明:`dist/components/notification/index.d.ts`。 类型中的 undefined 表示可省略;原始 prop 默认值不等于继承配置或服务默认值。
119
+
120
+ ### Props
121
+
122
+ | 名称 | 用途 | 公开类型 | 必填 | 声明默认值 |
123
+ | --- | --- | --- | --- | --- |
124
+ | position | 见场景用法与类型 | undefined &#124; "top-right" &#124; "top-left" &#124; "bottom-right" &#124; "bottom-left" | 否 | "top-right" |
125
+ | offset | 见场景用法与类型 | undefined &#124; number | 否 | 0 |
126
+ | title | 见场景用法与类型 | undefined &#124; string &#124; number &#124; () => VNodeChild &#124; VNode<RendererNode, RendererElement, { [key: string]: any; }> | 否 | undefined |
127
+ | type | 见场景用法与类型 | undefined &#124; "success" &#124; "warning" &#124; "strong" &#124; "info" &#124; "error" | 否 | "info" |
128
+ | message | 见场景用法与类型 | undefined &#124; string &#124; number &#124; () => VNodeChild &#124; VNode<RendererNode, RendererElement, { [key: string]: any; }> | 否 | undefined |
129
+ | duration | 见场景用法与类型 | undefined &#124; number | 否 | 3000 |
130
+ | showClose | 见场景用法与类型 | undefined &#124; false &#124; true | 否 | true |
131
+ | showIcon | 见场景用法与类型 | undefined &#124; false &#124; true | 否 | true |
132
+ | icon | 见场景用法与类型 | undefined &#124; () => VNodeChild &#124; VNode<RendererNode, RendererElement, { [key: string]: any; }> | 否 | 未声明 |
133
+ | footer | 见场景用法与类型 | undefined &#124; () => VNodeChild &#124; VNode<RendererNode, RendererElement, { [key: string]: any; }> | 否 | 未声明 |
134
+ | closeIcon | 见场景用法与类型 | undefined &#124; () => VNodeChild &#124; VNode<RendererNode, RendererElement, { [key: string]: any; }> | 否 | 未声明 |
135
+ | popupClass | 见场景用法与类型 | undefined &#124; string | 否 | undefined |
136
+ | resetOnUpdate | 见场景用法与类型 | undefined &#124; false &#124; true | 否 | false |
137
+ | onClose | 见场景用法与类型 | undefined &#124; () => void | 否 | 工厂函数(每个实例初始化;有效值见行为说明) |
138
+ | renderToBody | 见场景用法与类型 | undefined &#124; false &#124; true | 否 | false |
139
+
140
+ ### Events
141
+
142
+ | 事件 | 用途 | 监听器签名(即事件参数) |
143
+ | --- | --- | --- |
144
+ | close | 见场景用法与类型 | undefined &#124; () => void |
145
+ | destroy | 见场景用法与类型 | undefined &#124; (...args: any[]) => any |
146
+ | click | 见场景用法与类型 | undefined &#124; (...args: any[]) => any |
147
+
148
+ ### Slots
149
+
150
+ 公开类型未逐项声明插槽;本页场景说明列出实际使用的插槽,不将任意插槽视为已支持。
151
+
152
+ ### 实例方法
153
+
154
+ 没有检索到显式 expose 或 Options API methods 的公开方法;不把 setup 内部函数当成稳定实例 API。
155
+
156
+ ### 关联类型定义
157
+
158
+ 以下摘自本组件族声明,供查阅嵌套配置;运行时和值类型均以根入口可导出项为准。
159
+
160
+ ```typescript-reference
161
+ declare const types: readonly ["success", "strong", "warning", "error", "info"];
162
+
163
+ type NotificationType = (typeof types)[number];
164
+
165
+ type NotificationContent = string | number | RenderFunction | VNode;
166
+
167
+ interface NotificationOptions {
168
+ id?: string | number;
169
+ title?: NotificationContent;
170
+ message?: NotificationContent;
171
+ content?: NotificationContent;
172
+ type?: NotificationType;
173
+ duration?: number;
174
+ position?: NotificationPosition;
175
+ offset?: number;
176
+ renderTo?: string | HTMLElement;
177
+ showClose?: boolean;
178
+ closable?: boolean;
179
+ showIcon?: boolean;
180
+ icon?: RenderFunction | VNode;
181
+ footer?: RenderFunction | VNode;
182
+ closeIcon?: RenderFunction | VNode;
183
+ popupClass?: string;
184
+ class?: string;
185
+ style?: CSSProperties;
186
+ onClick?: () => void;
187
+ onClose?: (id?: string | number) => void;
188
+ }
189
+
190
+ type NotificationPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
191
+
192
+ type NotificationParams = NotificationOptions | NotificationContent;
193
+
194
+ interface NotificationReturn {
195
+ close(): void;
196
+ }
197
+
198
+ interface NotificationCaller {
199
+ (options: NotificationParams, appContext?: AppContext): NotificationReturn;
200
+ }
201
+
202
+ interface NotificationMethods extends NotificationCaller {
203
+ info(options: NotificationParams, appContext?: AppContext): NotificationReturn;
204
+ success(options: NotificationParams, appContext?: AppContext): NotificationReturn;
205
+ warning(options: NotificationParams, appContext?: AppContext): NotificationReturn;
206
+ strong(options: NotificationParams, appContext?: AppContext): NotificationReturn;
207
+ error(options: NotificationParams, appContext?: AppContext): NotificationReturn;
208
+ remove(id: string | number): void;
209
+ clear(position?: NotificationPosition): void;
210
+ }
211
+
212
+ interface NotificationItem {
213
+ id: string | number;
214
+ title?: NotificationContent;
215
+ message: NotificationContent;
216
+ type: NotificationType;
217
+ duration: number;
218
+ showClose: boolean;
219
+ showIcon: boolean;
220
+ icon?: RenderFunction | VNode;
221
+ footer?: RenderFunction | VNode;
222
+ closeIcon?: RenderFunction | VNode;
223
+ popupClass?: string;
224
+ class?: string;
225
+ style?: CSSProperties;
226
+ offset: number;
227
+ onClick?: () => void;
228
+ onClose?: (id?: string | number) => void;
229
+ resetOnUpdate?: boolean;
230
+ }
231
+
232
+ type NotificationProps = ExtractPropTypes<typeof notificationProps>;
233
+ ```
234
+
235
+
236
+ 返回 [Notification 用法](./notification.md)。