x-next 1.13.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 (138) 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 +380 -3
  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 +33651 -5
  124. package/CHANGELOG.md +18 -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/es/_utils/inherit-component-type.js +6 -0
  131. package/dist/es/components/date-picker/index.js +18 -17
  132. package/dist/es/components/form-input/index.js +12 -11
  133. package/dist/es/components/layout/index.js +10 -9
  134. package/dist/es/components/menu/hooks/use-level.js +5 -5
  135. package/dist/es/components/menu/index.js +13 -10
  136. package/dist/index.cjs +3 -3
  137. package/dist/index.umd.js +3 -3
  138. package/package.json +10 -5
@@ -1,12 +1,14 @@
1
1
  <!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
2
2
  # Checkbox AI 使用
3
3
 
4
- 适用版本:x-next@1.13.0;来源指纹:`18e9b8eefa53b4bd91134fb4486778509ccf3a8d614a1bd387a6d469b623ddcf`。
4
+ 适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
5
5
 
6
- 先读 [通用接入](../core.md)。公开导出:`Checkbox`;模型:v-model;已核对事件:change。
6
+ 先读 [通用接入](../core.md)。公开导出:`Checkbox, CheckboxGroup`;主要模型:v-model。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./checkbox-api.md),包含本组件族全部子组件和别名。
7
7
 
8
8
  按需样式:`x-next/style/form-checkbox`(包含 base.css、form-checkbox.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
9
9
 
10
+ ## 已核验行为与示例
11
+
10
12
  [组件文档与 live demo](https://x-next.yjmf.com/components/checkbox)。使用普通 `v-model`;模型支持 `boolean` 或 `(string | number | boolean)[]`,数组模式配合 `value`。`defaultChecked`、`disabled`、`indeterminate` 默认 `false`;半选状态不会替代模型值。
11
13
 
12
14
  `change(value, event)` 返回新值和原生 `Event`。默认插槽是文案,`checkbox` 插槽提供 `checked` / `disabled`。`id`、`name`、`required`、`form`、`tabindex`、`autofocus`、`autocomplete` 和 `aria-*` 传给原生复选框。
@@ -31,4 +33,364 @@ function changed(value: boolean | (string | number | boolean)[], event: Event) {
31
33
  </template>
32
34
  ```
33
35
 
34
- 返回 [AI 索引](../index.md)。精选示例不是完整 API 表,新能力先查同版本公开类型与组件文档。
36
+ ## 场景用法
37
+
38
+ 以下示例从本地 `src/docs/components/checkbox.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./checkbox-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
39
+
40
+ ### 用途与选型
41
+
42
+ 用于多选或开关式勾选,适合权限配置、批量选择、偏好设置等场景。
43
+
44
+
45
+ ### 何时使用
46
+
47
+ - 需要在一组互不排斥的选项中选择多个值。
48
+ - 需要展示全选、半选、最多可选等状态。
49
+ - 需要以单个布尔值表达是否启用某项配置。
50
+
51
+
52
+ ### 基础用法
53
+
54
+ ```vue
55
+ <script setup lang="ts">
56
+ import 'x-next/style.css';
57
+ import { Checkbox } from 'x-next';
58
+ import { ref } from 'vue';
59
+
60
+ const checked = ref(false);
61
+ </script>
62
+ <template>
63
+ <Checkbox v-model="checked">同意协议</Checkbox>
64
+ </template>
65
+ ```
66
+
67
+ ### 尺寸
68
+
69
+ ```vue
70
+ <script setup lang="ts">
71
+ import 'x-next/style.css';
72
+ import { Checkbox, CheckboxGroup } from 'x-next';
73
+ import { ref } from 'vue';
74
+
75
+ const checked = ref(true);
76
+ const values = ref(['read']);
77
+ const options = [
78
+ { label: '读取', value: 'read' },
79
+ { label: '写入', value: 'write' },
80
+ ];
81
+ </script>
82
+ <template>
83
+ <Checkbox v-model="checked" size="mini">mini</Checkbox>
84
+ <Checkbox v-model="checked" size="small">small</Checkbox>
85
+ <Checkbox v-model="checked" size="medium">medium</Checkbox>
86
+ <Checkbox v-model="checked" size="large">large</Checkbox>
87
+
88
+ <CheckboxGroup v-model="values" :options="options" size="mini" />
89
+ <CheckboxGroup v-model="values" :options="options" size="large" />
90
+ </template>
91
+ ```
92
+
93
+ ### 禁用状态
94
+
95
+ ```vue
96
+ <script setup lang="ts">
97
+ import 'x-next/style.css';
98
+ import { Checkbox } from 'x-next';
99
+ import { ref } from 'vue';
100
+
101
+ const checked = ref(true);
102
+ </script>
103
+ <template>
104
+ <Checkbox disabled>禁用未选</Checkbox>
105
+ <Checkbox v-model="checked" disabled>禁用已选</Checkbox>
106
+ </template>
107
+ ```
108
+
109
+ ### 半选状态
110
+
111
+ ```vue
112
+ <script setup lang="ts">
113
+ import 'x-next/style.css';
114
+ import { Checkbox, CheckboxGroup } from 'x-next';
115
+ import { computed, ref } from 'vue';
116
+
117
+ const values = ref(['read']);
118
+ const permissions = ['read', 'write', 'publish'];
119
+ const options = [
120
+ { label: '读取', value: 'read' },
121
+ { label: '写入', value: 'write' },
122
+ { label: '发布', value: 'publish' },
123
+ ];
124
+ const checkAll = computed({
125
+ get: () => permissions.every((value) => values.value.includes(value)),
126
+ set: (checked: boolean) => {
127
+ values.value = checked ? [...permissions] : [];
128
+ },
129
+ });
130
+ const isIndeterminate = computed(
131
+ () => values.value.length > 0 && values.value.length < permissions.length,
132
+ );
133
+ </script>
134
+ <template>
135
+ <Checkbox v-model="checkAll" :indeterminate="isIndeterminate">全选权限</Checkbox>
136
+ <CheckboxGroup v-model="values" :options="options" />
137
+ </template>
138
+ ```
139
+
140
+ ### 复选框组
141
+
142
+ ```vue
143
+ <script setup lang="ts">
144
+ import 'x-next/style.css';
145
+ import { CheckboxGroup } from 'x-next';
146
+ import { ref } from 'vue';
147
+
148
+ const values = ref(['read']);
149
+ const options = [
150
+ { label: '读取', value: 'read' },
151
+ { label: '写入', value: 'write' },
152
+ { label: '发布', value: 'publish' },
153
+ ];
154
+ </script>
155
+ <template>
156
+ <CheckboxGroup v-model="values" :options="options" />
157
+ </template>
158
+ ```
159
+
160
+ ### 纵向排列
161
+
162
+ ```vue
163
+ <script setup lang="ts">
164
+ import 'x-next/style.css';
165
+ import { CheckboxGroup } from 'x-next';
166
+ import { ref } from 'vue';
167
+
168
+ const values = ref(['email']);
169
+ const options = [
170
+ { label: '邮件', value: 'email' },
171
+ { label: '短信', value: 'sms', disabled: true },
172
+ { label: '站内信', value: 'notice' },
173
+ ];
174
+ </script>
175
+ <template>
176
+ <CheckboxGroup v-model="values" direction="vertical" :options="options" />
177
+ </template>
178
+ ```
179
+
180
+ ### 最多可选
181
+
182
+ ```vue
183
+ <script setup lang="ts">
184
+ import 'x-next/style.css';
185
+ import { CheckboxGroup } from 'x-next';
186
+ import { ref } from 'vue';
187
+
188
+ const values = ref(['read']);
189
+ const options = [
190
+ { label: '读取', value: 'read' },
191
+ { label: '写入', value: 'write' },
192
+ { label: '发布', value: 'publish' },
193
+ { label: '删除', value: 'delete' },
194
+ ];
195
+ </script>
196
+ <template>
197
+ <CheckboxGroup v-model="values" :options="options" :max="2" />
198
+ </template>
199
+ ```
200
+
201
+ ### 自定义文案
202
+
203
+ ```vue
204
+ <script setup lang="ts">
205
+ import 'x-next/style.css';
206
+ import { CheckboxGroup } from 'x-next';
207
+ import { ref } from 'vue';
208
+ const values = ref(['vue']);
209
+ const options = [{ label: 'Vue', value: 'vue' }, { label: 'TypeScript', value: 'ts' }];
210
+ </script>
211
+ <template>
212
+ <CheckboxGroup v-model="values" :options="options">
213
+ <template #label="{ data }">
214
+ <span>{{ data.label }}模块</span>
215
+ </template>
216
+ </CheckboxGroup>
217
+ </template>
218
+ ```
219
+
220
+ ### 自定义复选框图形
221
+
222
+ ```vue
223
+ <script setup lang="ts">
224
+ import 'x-next/style.css';
225
+ import { CheckboxGroup } from 'x-next';
226
+ import { ref } from 'vue';
227
+ const values = ref(['vue']);
228
+ const options = [{ label: 'Vue', value: 'vue' }, { label: 'TypeScript', value: 'ts' }];
229
+ </script>
230
+ <template>
231
+ <CheckboxGroup v-model="values" :options="options">
232
+ <template #checkbox="{ checked, disabled }">
233
+ <span :class="{ 'is-checked': checked, 'is-disabled': disabled }">
234
+ {{ checked ? '✓' : '' }}
235
+ </span>
236
+ </template>
237
+ </CheckboxGroup>
238
+ </template>
239
+ ```
240
+
241
+ ### 布尔值选项
242
+
243
+ ```vue
244
+ <script setup lang="ts">
245
+ import 'x-next/style.css';
246
+ import { CheckboxGroup } from 'x-next';
247
+ import { ref } from 'vue';
248
+
249
+ const values = ref([true]);
250
+ const options = [
251
+ { label: '启用', value: true },
252
+ { label: '停用', value: false },
253
+ ];
254
+ </script>
255
+ <template>
256
+ <CheckboxGroup v-model="values" :options="options" />
257
+ </template>
258
+ ```
259
+
260
+ ### 事件
261
+
262
+ ```vue
263
+ <script setup lang="ts">
264
+ import 'x-next/style.css';
265
+ import { CheckboxGroup } from 'x-next';
266
+ const groupOptions = [
267
+ { label: '读取', value: 'read' },
268
+ { label: '写入', value: 'write' },
269
+ { label: '发布', value: 'publish' },
270
+ ];
271
+
272
+ import { ref } from 'vue';
273
+
274
+ const values = ref(['read']);
275
+ const handleChange = (value: Array<string | number | boolean>) => {
276
+ console.log(value);
277
+ };
278
+ const options = groupOptions;
279
+ </script>
280
+ <template>
281
+ <CheckboxGroup v-model="values" :options="options" @change="handleChange" />
282
+ </template>
283
+ ```
284
+
285
+ ### 在 Form 中校验
286
+
287
+ 组件放进 `x-form-item` 后会自动继承 Form 的尺寸与禁用状态,并按 FormItem 的校验规则展示错误。默认 `validateTrigger` 为 `change`,即值变化时触发校验。
288
+
289
+ ```vue
290
+ <script setup lang="ts">
291
+ import 'x-next/style.css';
292
+ import { Form, FormItem, CheckboxGroup, Checkbox, Space, Button } from 'x-next';
293
+ import { reactive, ref } from 'vue';
294
+ import type { FormInstance, FieldRule } from 'x-next';
295
+
296
+ const formState = reactive({ features: [] as string[] });
297
+ const formRules: Record<string, FieldRule[]> = {
298
+ features: [{ type: 'array', required: true, message: '至少选择一项功能' }],
299
+ };
300
+ const formRef = ref<FormInstance>();
301
+ const validateResult = ref('');
302
+
303
+ const handleValidate = async () => {
304
+ const errors = await formRef.value!.validate();
305
+ validateResult.value = errors
306
+ ? `校验失败:${Object.values(errors).map((error) => error.message).join(';')}`
307
+ : '校验通过';
308
+ };
309
+ const handleReset = () => {
310
+ formRef.value!.resetFields();
311
+ validateResult.value = '已重置';
312
+ };
313
+ </script>
314
+ <template>
315
+ <Form ref="formRef" :model="formState" :rules="formRules">
316
+ <FormItem field="features" label="功能">
317
+ <CheckboxGroup v-model="formState.features">
318
+ <Checkbox value="report">报表</Checkbox>
319
+ <Checkbox value="alert">告警</Checkbox>
320
+ </CheckboxGroup>
321
+ </FormItem>
322
+ <FormItem>
323
+ <Space>
324
+ <Button type="primary" @click="handleValidate">校验</Button>
325
+ <Button @click="handleReset">重置</Button>
326
+ </Space>
327
+ </FormItem>
328
+ </Form>
329
+ <p role="status">{{ validateResult }}</p>
330
+ </template>
331
+ ```
332
+
333
+ ### 原生表单属性
334
+
335
+ `id`、`name`、`required`、`form`、`tabindex`、`autofocus`、`autocomplete` 和 `aria-*` 传给内部原生 checkbox input。`class`、`style`、`data-*` 等容器属性保留在外层 label;组件自行管理 `checked`、`disabled` 和 `aria-checked`。组件本身就是 label,不要再嵌套外层 label。
336
+
337
+ 下面的 Checkbox 位于表单外,通过 `form` 关联原生表单。未勾选时浏览器阻止提交;勾选后 `FormData` 能取得 `name` 对应的值。单纯传 `required` 不会创建 x-form 的校验规则。
338
+
339
+ ```vue
340
+ <script setup lang="ts">
341
+ import { ref } from 'vue';
342
+ import { Button, Checkbox } from 'x-next';
343
+ import 'x-next/dist/style.css';
344
+
345
+ const agreement = ref(false);
346
+ const result = ref('');
347
+ function submit(event: Event) {
348
+ result.value = String(new FormData(event.currentTarget as HTMLFormElement).get('agreement'));
349
+ }
350
+ import type { InputHTMLAttributes } from 'vue';
351
+ const nativeAttrs1 = { "name": "agreement", "form": "agreement-form", "required": true } satisfies InputHTMLAttributes;
352
+ </script>
353
+ <template>
354
+ <form id="agreement-form" @submit.prevent="submit">
355
+ <Button html-type="submit">提交</Button>
356
+ </form>
357
+ <Checkbox v-bind="nativeAttrs1" v-model="agreement" value="accepted" >同意协议</Checkbox>
358
+ <p role="status">{{ result }}</p>
359
+ </template>
360
+ ```
361
+
362
+ ### 键盘与可见焦点
363
+
364
+ 按 Tab 进入复选框,Space 勾选或取消。普通主题和系统高对比度模式都显示组件外框,已选、半选和自定义图形不会隐藏焦点。禁用项不进入 Tab 顺序。原生 input 保留有效透明点击盒,角色定位可以直接勾选,不需要 force。
365
+
366
+ ```vue
367
+ <script setup lang="ts">
368
+ import 'x-next/style.css';
369
+ import { ref } from 'vue';
370
+ import { Checkbox } from 'x-next';
371
+ import 'x-next/style/form-checkbox';
372
+ const checked = ref(true);
373
+ const custom = ref(false);
374
+ const defaultAttrs = { 'aria-label': '键盘默认复选框' };
375
+ const customAttrs = { 'aria-label': '键盘自定义复选框' };
376
+ </script>
377
+ <template>
378
+ <button type="button">从这里按 Tab</button>
379
+ <Checkbox v-model="checked" v-bind="defaultAttrs">默认图形,初始已选</Checkbox>
380
+ <Checkbox v-model="custom" v-bind="customAttrs">
381
+ <template #checkbox="{ checked: selected }">
382
+ <span class="custom-check" :class="{ selected }">{{ selected ? '✓' : '' }}</span>
383
+ </template>
384
+ 自定义图形
385
+ </Checkbox>
386
+ <Checkbox disabled>禁用项跳过</Checkbox>
387
+ <p role="status">默认:{{ checked }};自定义:{{ custom }}</p>
388
+ </template>
389
+ <style scoped>
390
+ .custom-check { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border: 1px solid currentColor; }
391
+ .selected { background: var(--x-color-primary-6); color: white; }
392
+ </style>
393
+ ```
394
+
395
+
396
+ 返回 [AI 索引](../index.md)。先查本页与 [本地 API](./checkbox-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。
@@ -0,0 +1,52 @@
1
+ <!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
2
+ # ColorPicker 完整公开 API
3
+
4
+ 适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
5
+
6
+ 从同版本构建的公开声明、运行时 props/emits 和显式 expose 生成。运行时导入始终使用 `x-next`,声明路径仅作定位。插槽类型未细化时,具体槽名与作用域见本地用法示例。
7
+
8
+ ## ColorPicker API
9
+
10
+ 公开声明:`dist/components/color-picker/index.d.ts`。 类型中的 undefined 表示可省略;原始 prop 默认值不等于继承配置或服务默认值。
11
+
12
+ ### Props
13
+
14
+ | 名称 | 用途 | 公开类型 | 必填 | 声明默认值 |
15
+ | --- | --- | --- | --- | --- |
16
+ | modelValue | 颜色值,支持 hex / rgb / hsl | undefined &#124; string | 否 | undefined |
17
+ | defaultValue | 非受控初值 | undefined &#124; string | 否 | undefined |
18
+ | show | 面板是否可见(受控) | undefined &#124; false &#124; true | 否 | undefined |
19
+ | defaultShow | 面板默认是否可见 | undefined &#124; false &#124; true | 否 | false |
20
+ | modes | 可选的颜色格式 | undefined &#124; ColorFormat[] | 否 | 工厂函数(每个实例初始化;有效值见行为说明) |
21
+ | showAlpha | 是否启用透明度 | undefined &#124; false &#124; true | 否 | true |
22
+ | swatches | 预设色块 | undefined &#124; string[] | 否 | [] |
23
+ | showConfirm | 是否展示确认按钮 | undefined &#124; false &#124; true | 否 | true |
24
+ | showClear | 是否展示清除按钮 | undefined &#124; false &#124; true | 否 | true |
25
+ | disabled | 是否禁用 | undefined &#124; false &#124; true | 否 | false |
26
+ | size | 尺寸 | undefined &#124; "mini" &#124; "small" &#124; "medium" &#124; "large" | 否 | 未声明 |
27
+ | popupContainer | 面板挂载容器 | undefined &#124; string &#124; HTMLElement | 否 | 未声明 |
28
+
29
+ ### Events
30
+
31
+ | 事件 | 用途 | 监听器签名(即事件参数) |
32
+ | --- | --- | --- |
33
+ | update:modelValue | 颜色变化 | undefined &#124; (_value: string, _ev?: Event &#124; undefined) => any |
34
+ | change | 颜色变化 | undefined &#124; (_value: string, _ev?: Event &#124; undefined) => any |
35
+ | update:show | 面板显隐变化 | undefined &#124; (_visible: boolean) => any |
36
+ | showChange | 面板显隐变化 | undefined &#124; (_visible: boolean) => any |
37
+ | confirm | 点击确认按钮 | undefined &#124; (_value: string) => any |
38
+ | clear | 点击清除按钮 | undefined &#124; () => any |
39
+
40
+ ### Slots
41
+
42
+ | 名称 | 用途 | 公开类型 |
43
+ | --- | --- | --- |
44
+ | default | 触发器内的补充内容 | undefined &#124; () => unknown |
45
+ | trigger | 自定义触发器,将 triggerAttrs 绑定到实际按钮 | undefined &#124; (props: { value: string; visible: boolean; triggerAttrs: ButtonHTMLAttributes & VNodeProps; }) => unknown |
46
+
47
+ ### 实例方法
48
+
49
+ 没有检索到显式 expose 或 Options API methods 的公开方法;不把 setup 内部函数当成稳定实例 API。
50
+
51
+
52
+ 返回 [ColorPicker 用法](./color-picker.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
  # ColorPicker AI 使用
3
3
 
4
- 适用版本:x-next@1.13.0;来源指纹:`18e9b8eefa53b4bd91134fb4486778509ccf3a8d614a1bd387a6d469b623ddcf`。
4
+ 适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
5
5
 
6
- 先读 [通用接入](../core.md)。公开导出:`ColorPicker`;模型:v-model、v-model:show;已核对事件:change、showChange、clear、confirm。
6
+ 先读 [通用接入](../core.md)。公开导出:`ColorPicker`;主要模型:v-model、v-model:show。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./color-picker-api.md),包含本组件族全部子组件和别名。
7
7
 
8
8
  按需样式:`x-next/style/color-picker`(包含 base.css、color-picker.css、button.css、form-input.css、form-input-number.css、trigger.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
9
9
 
10
+ ## 已核验行为与示例
11
+
10
12
  [组件文档与 live demo](https://x-next.yjmf.com/components/color-picker)。`v-model` 输出 hex 字符串;`v-model:show` 控制面板。清除恢复显式 defaultValue,未提供则提交空字符串;change、clear、confirm 都通知 Form 的 change 通道。自定义触发器将 triggerAttrs 绑定到原生按钮,保留键盘、ARIA、禁用与焦点行为。
11
13
 
12
14
  ```vue
@@ -33,4 +35,210 @@ const pickerAttrs = { id: 'brand-color', 'aria-label': '品牌色' };
33
35
  </template>
34
36
  ```
35
37
 
36
- 返回 [AI 索引](../index.md)。精选示例不是完整 API 表,新能力先查同版本公开类型与组件文档。
38
+ ## 场景用法
39
+
40
+ 以下示例从本地 `src/docs/components/color-picker.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./color-picker-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
41
+
42
+ ### 用途与选型
43
+
44
+ 用于选择颜色值,支持 hex / rgb / hsl 三种格式与透明度。
45
+
46
+
47
+ ### 何时使用
48
+
49
+ - 需要让用户从任意颜色中挑选一个(品牌色、标签色、图表配色)。
50
+ - 需要精确输入颜色值(设计稿给定 hex,或按 rgb/hsl 通道微调)。
51
+ - 提供预设色板时,可同时给出 `swatches` 让用户快速选择。
52
+
53
+
54
+ ### 基础用法
55
+
56
+ `v-model` 绑定的是颜色字符串。点击色块展开面板,拖动取色区或色相条调整颜色。
57
+
58
+ ```vue
59
+ <script setup lang="ts">
60
+ import 'x-next/style.css';
61
+ import { ColorPicker } from 'x-next';
62
+ import { ref } from 'vue';
63
+
64
+ const value = ref('#165dff');
65
+ </script>
66
+ <template>
67
+ <ColorPicker v-model="value" />
68
+ <p role="status">{{ value }}</p>
69
+ </template>
70
+ ```
71
+
72
+ ### 受控值与事件
73
+
74
+ `change` 在颜色变化时触发,携带当前颜色字符串。
75
+
76
+ ```vue
77
+ <script setup lang="ts">
78
+ import 'x-next/style.css';
79
+ import { ColorPicker } from 'x-next';
80
+ import { ref } from 'vue';
81
+
82
+ const value = ref('#00b42a');
83
+ const changeLog = ref('等待操作');
84
+
85
+ const handleChange = (value: string) => {
86
+ changeLog.value = `change: ${value}`;
87
+ };
88
+ </script>
89
+ <template>
90
+ <ColorPicker v-model="value" @change="handleChange" />
91
+ <p role="status">{{ changeLog }}</p>
92
+ </template>
93
+ ```
94
+
95
+ ### 透明度
96
+
97
+ 默认开启透明度(`showAlpha`),面板会多出透明度条,输出值为 8 位 hex。关闭后会忽略 alpha。
98
+
99
+ ```vue
100
+ <script setup lang="ts">
101
+ import 'x-next/style.css';
102
+ import { ColorPicker } from 'x-next';
103
+ import { ref } from 'vue';
104
+
105
+ const value = ref('#f53f3f80');
106
+ </script>
107
+ <template>
108
+ <ColorPicker v-model="value" />
109
+ <ColorPicker :default-value="value" :show-alpha="false" />
110
+ </template>
111
+ ```
112
+
113
+ ### 格式切换
114
+
115
+ `modes` 决定面板中可切换的输入格式。只给 `hex` 时面板只显示一个文本输入框。
116
+
117
+ ```vue
118
+ <script setup lang="ts">
119
+ import 'x-next/style.css';
120
+ import { ColorPicker } from 'x-next';
121
+ import { ref } from 'vue';
122
+
123
+ const value = ref('#ff7d00');
124
+ </script>
125
+ <template>
126
+ <ColorPicker v-model="value" :modes="['hex']" />
127
+ <ColorPicker v-model="value" :modes="['hex', 'rgb']" />
128
+ <ColorPicker v-model="value" :modes="['hex', 'rgb', 'hsl']" />
129
+ </template>
130
+ ```
131
+
132
+ ### 预设颜色
133
+
134
+ `swatches` 提供预设色块,点击后取色区、滑轨与输入框会同步。
135
+
136
+ ```vue
137
+ <script setup lang="ts">
138
+ import 'x-next/style.css';
139
+ import { ColorPicker } from 'x-next';
140
+ import { ref } from 'vue';
141
+
142
+ const value = ref('#722ed1');
143
+ const swatches = ['#165dff', '#00b42a', '#ff7d00', '#f53f3f', '#722ed1'];
144
+ </script>
145
+ <template>
146
+ <ColorPicker v-model="value" :swatches="swatches" />
147
+ <p role="status">{{ value }}</p>
148
+ </template>
149
+ ```
150
+
151
+ ### 尺寸与禁用
152
+
153
+ `size` 与表单控件一致;`disabled` 会禁用触发器与面板内所有交互。
154
+
155
+ ```vue
156
+ <script setup lang="ts">
157
+ import 'x-next/style.css';
158
+ import { ColorPicker } from 'x-next';
159
+ import { ref } from 'vue';
160
+
161
+ const value = ref('#0fc6c2');
162
+ </script>
163
+ <template>
164
+ <ColorPicker v-model="value" size="mini" />
165
+ <ColorPicker v-model="value" size="small" />
166
+ <ColorPicker v-model="value" size="medium" />
167
+ <ColorPicker v-model="value" size="large" />
168
+ <ColorPicker v-model="value" disabled />
169
+ </template>
170
+ ```
171
+
172
+ ### 自定义触发器
173
+
174
+ `trigger` 插槽可替换默认色块按钮;将 `triggerAttrs` 绑定到实际按钮,保留禁用、表单标签、面板关联、键盘打开与焦点归还。`default` 插槽内容会渲染在色块旁边。
175
+
176
+ ```vue
177
+ <script setup lang="ts">
178
+ import 'x-next/style.css';
179
+ import { ColorPicker } from 'x-next';
180
+ import { ref } from 'vue';
181
+
182
+ const value = ref('#165dff');
183
+ </script>
184
+ <template>
185
+ <ColorPicker v-model="value">
186
+ <template #trigger="{ value, visible, triggerAttrs }">
187
+ <button v-bind="triggerAttrs">{{ visible ? '选择中' : value }}</button>
188
+ </template>
189
+ </ColorPicker>
190
+ </template>
191
+ ```
192
+
193
+ ### 在 Form 中校验
194
+
195
+ 打开面板后点「清除」会将未配置 `defaultValue` 的字段设为空,并触发 change 校验;确认也会通知 Form。输入框编辑仅属于面板,不会抢占业务字段的标签关联。
196
+
197
+ ```vue
198
+ <script setup lang="ts">
199
+ import 'x-next/style.css';
200
+ import { Form, FormItem, ColorPicker, Button } from 'x-next';
201
+ import { reactive, ref } from 'vue';
202
+ import type { FormInstance, FieldRule } from 'x-next';
203
+
204
+ const formRef = ref<FormInstance>();
205
+ const formModel = reactive({ brandColor: '#165dff' });
206
+ const swatches = ['#165dff', '#00b42a', '#ff7d00'];
207
+ const result = ref('');
208
+ const rules: Record<string, FieldRule[]> = {
209
+ brandColor: [{ required: true, message: '请选择品牌色' }],
210
+ };
211
+
212
+ const handleValidate = async () => {
213
+ const errors = await formRef.value!.validate();
214
+ result.value = errors ? '校验失败' : '校验通过';
215
+ };
216
+ const handleReset = () => {
217
+ formRef.value!.resetFields();
218
+ result.value = '已重置';
219
+ };
220
+ </script>
221
+ <template>
222
+ <Form ref="formRef" :model="formModel" :rules="rules" layout="vertical">
223
+ <FormItem field="brandColor" label="品牌色" validate-trigger="change">
224
+ <ColorPicker v-model="formModel.brandColor" :swatches="swatches" />
225
+ </FormItem>
226
+ </Form>
227
+ <Button type="primary" size="small" @click="handleValidate">校验</Button>
228
+ <Button size="small" @click="handleReset">重置</Button>
229
+ <p role="status">{{ result }}</p>
230
+ </template>
231
+ ```
232
+
233
+ ### 交互说明
234
+
235
+ - **值形态**:`v-model` 始终输出 hex 字符串(`showAlpha` 开启且存在透明度时为 8 位),便于持久化;面板内部允许按 rgb / hsl 输入后再换算。
236
+ - **键盘操作**:默认触发按钮支持 Enter、Space、ArrowDown 打开并进入面板。取色区与两条滑轨都可聚焦,方向键微调(按住 Shift 步长更大);`Esc` 关闭面板并把焦点还给触发器。
237
+ - **颜色解析**:支持 `#rgb` / `#rgba` / `#rrggbb` / `#rrggbbaa`、`rgb()` / `rgba()`、`hsl()` / `hsla()`,逗号与空格语法均可。传空或非法值时面板回退到兜底色,不会崩溃。
238
+ - **受控显隐**:传入 `show` 后组件不再自行改变显隐状态,需监听 `showChange` 更新。
239
+ - **指针操作**:取色区与滑轨使用 PointerEvent 支持鼠标、触摸和笔;取消、窗口失焦、禁用或卸载会结束拖拽,并保留 MouseEvent 回退。触摸设备的实际手势体验仍需设备验收。
240
+ - **清除语义**:设置了 `defaultValue` 时清除恢复该默认值;否则提交空字符串,触发器使用兜底色显示。
241
+
242
+
243
+
244
+ 返回 [AI 索引](../index.md)。先查本页与 [本地 API](./color-picker-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。