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.
- 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 +380 -3
- 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 +33651 -5
- package/CHANGELOG.md +18 -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/es/_utils/inherit-component-type.js +6 -0
- package/dist/es/components/date-picker/index.js +18 -17
- package/dist/es/components/form-input/index.js +12 -11
- package/dist/es/components/layout/index.js +10 -9
- package/dist/es/components/menu/hooks/use-level.js +5 -5
- package/dist/es/components/menu/index.js +13 -10
- package/dist/index.cjs +3 -3
- package/dist/index.umd.js +3 -3
- 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
|
# DatePicker AI 使用
|
|
3
3
|
|
|
4
|
-
适用版本:x-next@1.
|
|
4
|
+
适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
|
|
5
5
|
|
|
6
|
-
先读 [通用接入](../core.md)。公开导出:`DatePicker
|
|
6
|
+
先读 [通用接入](../core.md)。公开导出:`DatePicker, MonthPicker, QuarterPicker, RangePicker, WeekPicker, YearPicker`;主要模型:v-model、v-model:popup-visible。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./date-picker-api.md),包含本组件族全部子组件和别名。
|
|
7
7
|
|
|
8
8
|
按需样式:`x-next/style/date-picker`(包含 base.css、button.css、date-picker.css、scrollbar-v2.css、time-picker.css、trigger.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
|
|
9
9
|
|
|
10
|
+
## 已核验行为与示例
|
|
11
|
+
|
|
10
12
|
[组件文档与 live demo](https://x-next.yjmf.com/components/date-picker)。默认 `type='date'`、`allowClear=true`、`showToday=true`、`showTime=false`、`position='bl'`。`format` 控制显示,`valueFormat` 控制输出;本例使用 `'YYYY-MM-DD'` 字符串。公开 `DatePickerModelValue` 还包含数字、Date、数组和 `undefined`。
|
|
11
13
|
|
|
12
14
|
`change(value, date, dateString)` 为提交值,`select` 是面板选择;后两个参数声明为 `unknown`。清空返回 `undefined`,本例归一化为 `''` 保持受控。支持 `cell` / `extra` / `prefix` / `suffix-icon` 插槽;带时间选择需确认后提交。
|
|
@@ -31,4 +33,377 @@ function changed(value: DatePickerModelValue, _date: unknown, _text: unknown) {
|
|
|
31
33
|
</template>
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
## 场景用法
|
|
37
|
+
|
|
38
|
+
以下示例从本地 `src/docs/components/date-picker.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./date-picker-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
|
|
39
|
+
|
|
40
|
+
### 用途与选型
|
|
41
|
+
|
|
42
|
+
用于在表单、筛选和业务配置中输入或选择日期,也可以选择月份、年份、季度、周和日期范围。只需要选择一天内具体时间时,请使用 [TimePicker 时间选择器](./time-picker.md)。
|
|
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 { DatePicker } from 'x-next';
|
|
58
|
+
import { ref } from 'vue';
|
|
59
|
+
|
|
60
|
+
const date = ref('2026-06-04');
|
|
61
|
+
</script>
|
|
62
|
+
<template>
|
|
63
|
+
<DatePicker v-model="date" />
|
|
64
|
+
</template>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 受控值和事件
|
|
68
|
+
|
|
69
|
+
```vue
|
|
70
|
+
<script setup lang="ts">
|
|
71
|
+
import 'x-next/style.css';
|
|
72
|
+
import { DatePicker } from 'x-next';
|
|
73
|
+
import { ref } from 'vue';
|
|
74
|
+
|
|
75
|
+
const date = ref('2026-06-04');
|
|
76
|
+
const popupVisible = ref(false);
|
|
77
|
+
const handleSelect = (value: import('x-next').DatePickerModelValue) => console.log('select', value);
|
|
78
|
+
const handleChange = (value: import('x-next').DatePickerModelValue) => console.log('change', value);
|
|
79
|
+
const handleClear = () => console.log('clear');
|
|
80
|
+
</script>
|
|
81
|
+
<template>
|
|
82
|
+
<DatePicker
|
|
83
|
+
v-model="date"
|
|
84
|
+
v-model:popup-visible="popupVisible"
|
|
85
|
+
allow-clear
|
|
86
|
+
@select="handleSelect"
|
|
87
|
+
@change="handleChange"
|
|
88
|
+
@clear="handleClear"
|
|
89
|
+
/>
|
|
90
|
+
</template>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 月份、年份、季度和周
|
|
94
|
+
|
|
95
|
+
```vue
|
|
96
|
+
<script setup lang="ts">
|
|
97
|
+
import 'x-next/style.css';
|
|
98
|
+
import { MonthPicker, YearPicker, QuarterPicker, WeekPicker } from 'x-next';
|
|
99
|
+
import { ref } from 'vue';
|
|
100
|
+
|
|
101
|
+
const month = ref('2026-06');
|
|
102
|
+
const year = ref('2026');
|
|
103
|
+
const quarter = ref('2026-Q2');
|
|
104
|
+
const week = ref('2026-23rd');
|
|
105
|
+
</script>
|
|
106
|
+
<template>
|
|
107
|
+
<MonthPicker v-model="month" />
|
|
108
|
+
<YearPicker v-model="year" />
|
|
109
|
+
<QuarterPicker v-model="quarter" />
|
|
110
|
+
<WeekPicker v-model="week" />
|
|
111
|
+
</template>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 日期范围
|
|
115
|
+
|
|
116
|
+
```vue
|
|
117
|
+
<script setup lang="ts">
|
|
118
|
+
import 'x-next/style.css';
|
|
119
|
+
import { RangePicker } from 'x-next';
|
|
120
|
+
import { ref } from 'vue';
|
|
121
|
+
|
|
122
|
+
const range = ref(['2026-06-01', '2026-06-30']);
|
|
123
|
+
</script>
|
|
124
|
+
<template>
|
|
125
|
+
<RangePicker v-model="range" />
|
|
126
|
+
</template>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 中国农历展示
|
|
130
|
+
|
|
131
|
+
```vue
|
|
132
|
+
<script setup lang="ts">
|
|
133
|
+
import 'x-next/style.css';
|
|
134
|
+
import { DatePicker, RangePicker } from 'x-next';
|
|
135
|
+
import { ref } from 'vue';
|
|
136
|
+
|
|
137
|
+
const date = ref('2026-02-17');
|
|
138
|
+
const range = ref(['2026-06-19', '2026-09-25']);
|
|
139
|
+
</script>
|
|
140
|
+
<template>
|
|
141
|
+
<DatePicker v-model="date" show-lunar />
|
|
142
|
+
<RangePicker
|
|
143
|
+
v-model="range"
|
|
144
|
+
:show-lunar="{ showSolarFestival: true }"
|
|
145
|
+
/>
|
|
146
|
+
</template>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 带时间的日期选择
|
|
150
|
+
|
|
151
|
+
```vue
|
|
152
|
+
<script setup lang="ts">
|
|
153
|
+
import 'x-next/style.css';
|
|
154
|
+
import { DatePicker, RangePicker } from 'x-next';
|
|
155
|
+
import { ref } from 'vue';
|
|
156
|
+
|
|
157
|
+
const dateTime = ref('2026-06-04 09:30:00');
|
|
158
|
+
const dateTimeRange = ref(['2026-06-02 00:00:00', '2026-07-29 09:09:06']);
|
|
159
|
+
</script>
|
|
160
|
+
<template>
|
|
161
|
+
<DatePicker v-model="dateTime" show-time />
|
|
162
|
+
<RangePicker v-model="dateTimeRange" show-time />
|
|
163
|
+
</template>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 月范围和受控面板
|
|
167
|
+
|
|
168
|
+
```vue
|
|
169
|
+
<script setup lang="ts">
|
|
170
|
+
import 'x-next/style.css';
|
|
171
|
+
import { RangePicker, DatePicker } from 'x-next';
|
|
172
|
+
import { ref } from 'vue';
|
|
173
|
+
|
|
174
|
+
const monthRange = ref(['2026-01', '2026-06']);
|
|
175
|
+
const date = ref('2026-06-04');
|
|
176
|
+
const panel = ref('2026-06-01');
|
|
177
|
+
</script>
|
|
178
|
+
<template>
|
|
179
|
+
<RangePicker v-model="monthRange" mode="month" />
|
|
180
|
+
<DatePicker
|
|
181
|
+
v-model="date"
|
|
182
|
+
v-model:picker-value="panel"
|
|
183
|
+
show-confirm-btn
|
|
184
|
+
/>
|
|
185
|
+
</template>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### 动态范围限制
|
|
189
|
+
|
|
190
|
+
```vue
|
|
191
|
+
<script setup lang="ts">
|
|
192
|
+
import 'x-next/style.css';
|
|
193
|
+
import { RangePicker } from 'x-next';
|
|
194
|
+
import { ref } from 'vue';
|
|
195
|
+
|
|
196
|
+
const range = ref<string[]>([]);
|
|
197
|
+
const draft = ref<string[]>([]);
|
|
198
|
+
|
|
199
|
+
const disabledDate = (current: Date, type?: 'start' | 'end') => {
|
|
200
|
+
if (type !== 'end' || !draft.value[0]) return false;
|
|
201
|
+
const start = new Date(draft.value[0]).getTime();
|
|
202
|
+
const target = current.getTime();
|
|
203
|
+
return Math.abs(target - start) > 7 * 24 * 60 * 60 * 1000;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const handleCalendarChange = (value: string[]) => {
|
|
207
|
+
draft.value = value.filter(Boolean);
|
|
208
|
+
};
|
|
209
|
+
</script>
|
|
210
|
+
<template>
|
|
211
|
+
<RangePicker
|
|
212
|
+
v-model="range"
|
|
213
|
+
:disabled-date="disabledDate"
|
|
214
|
+
@calendar-change="handleCalendarChange"
|
|
215
|
+
/>
|
|
216
|
+
</template>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### 尺寸
|
|
220
|
+
|
|
221
|
+
```vue
|
|
222
|
+
<script setup lang="ts">
|
|
223
|
+
import 'x-next/style.css';
|
|
224
|
+
import { DatePicker } from 'x-next';
|
|
225
|
+
import { ref } from 'vue';
|
|
226
|
+
const date = ref('2026-09-30');
|
|
227
|
+
</script>
|
|
228
|
+
<template>
|
|
229
|
+
<DatePicker v-model="date" size="mini" />
|
|
230
|
+
<DatePicker v-model="date" size="small" />
|
|
231
|
+
<DatePicker v-model="date" size="medium" />
|
|
232
|
+
<DatePicker v-model="date" size="large" />
|
|
233
|
+
</template>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### 状态
|
|
237
|
+
|
|
238
|
+
```vue
|
|
239
|
+
<script setup lang="ts">
|
|
240
|
+
import 'x-next/style.css';
|
|
241
|
+
import { DatePicker } from 'x-next';
|
|
242
|
+
import { ref } from 'vue';
|
|
243
|
+
const date = ref('2026-09-30');
|
|
244
|
+
</script>
|
|
245
|
+
<template>
|
|
246
|
+
<DatePicker v-model="date" allow-clear />
|
|
247
|
+
<DatePicker default-value="2026-06-04" readonly />
|
|
248
|
+
<DatePicker default-value="2026-06-04" disabled />
|
|
249
|
+
<DatePicker v-model="date" error />
|
|
250
|
+
</template>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### 禁用日期
|
|
254
|
+
|
|
255
|
+
```vue
|
|
256
|
+
<script setup lang="ts">
|
|
257
|
+
import 'x-next/style.css';
|
|
258
|
+
import { DatePicker } from 'x-next';
|
|
259
|
+
import { ref } from 'vue';
|
|
260
|
+
|
|
261
|
+
const date = ref('2026-06-04');
|
|
262
|
+
const disabledDate = (current: Date) => {
|
|
263
|
+
const day = current.getDay();
|
|
264
|
+
return day === 0 || day === 6;
|
|
265
|
+
};
|
|
266
|
+
</script>
|
|
267
|
+
<template>
|
|
268
|
+
<DatePicker v-model="date" :disabled-date="disabledDate" />
|
|
269
|
+
</template>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### 禁止键盘输入
|
|
273
|
+
|
|
274
|
+
```vue
|
|
275
|
+
<script setup lang="ts">
|
|
276
|
+
import 'x-next/style.css';
|
|
277
|
+
import { DatePicker } from 'x-next';
|
|
278
|
+
import { ref } from 'vue';
|
|
279
|
+
|
|
280
|
+
const date = ref('2026-06-04');
|
|
281
|
+
</script>
|
|
282
|
+
<template>
|
|
283
|
+
<DatePicker v-model="date" input-read-only />
|
|
284
|
+
</template>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### 快捷项和值格式
|
|
288
|
+
|
|
289
|
+
```vue
|
|
290
|
+
<script setup lang="ts">
|
|
291
|
+
import 'x-next/style.css';
|
|
292
|
+
import { DatePicker } from 'x-next';
|
|
293
|
+
import { ref } from 'vue';
|
|
294
|
+
|
|
295
|
+
const date = ref('');
|
|
296
|
+
const shortcuts = [
|
|
297
|
+
{ label: '今天', value: () => new Date() },
|
|
298
|
+
{ label: '本月初', value: '2026-06-01' },
|
|
299
|
+
];
|
|
300
|
+
</script>
|
|
301
|
+
<template>
|
|
302
|
+
<DatePicker
|
|
303
|
+
v-model="date"
|
|
304
|
+
value-format="timestamp"
|
|
305
|
+
:shortcuts="shortcuts"
|
|
306
|
+
/>
|
|
307
|
+
</template>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### 自定义内容
|
|
311
|
+
|
|
312
|
+
```vue
|
|
313
|
+
<script setup lang="ts">
|
|
314
|
+
import 'x-next/style.css';
|
|
315
|
+
import { DatePicker } from 'x-next';
|
|
316
|
+
import { ref } from 'vue';
|
|
317
|
+
const date = ref('2026-09-30');
|
|
318
|
+
</script>
|
|
319
|
+
<template>
|
|
320
|
+
<DatePicker v-model="date">
|
|
321
|
+
<template #prefix>交付</template>
|
|
322
|
+
<template #suffix-icon>📅</template>
|
|
323
|
+
<template #cell="{ label }">
|
|
324
|
+
<strong>{{ label }}</strong>
|
|
325
|
+
</template>
|
|
326
|
+
<template #extra>选择值:{{ date || '未选择' }}</template>
|
|
327
|
+
</DatePicker>
|
|
328
|
+
</template>
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### 表单组合
|
|
332
|
+
|
|
333
|
+
```vue
|
|
334
|
+
<script setup lang="ts">
|
|
335
|
+
import 'x-next/style.css';
|
|
336
|
+
import { Form, FormItem, DatePicker, RangePicker, Space, Button } from 'x-next';
|
|
337
|
+
import { reactive, ref } from 'vue';
|
|
338
|
+
import type { FormInstance, FieldRule } from 'x-next';
|
|
339
|
+
const formRef = ref<FormInstance>();
|
|
340
|
+
const formModel = reactive({ date: '', range: ['2026-06-01', '2026-06-30'] });
|
|
341
|
+
const formResult = ref('点击校验查看结果');
|
|
342
|
+
const handleFormValidate = async () => {
|
|
343
|
+
const errors = await formRef.value!.validate();
|
|
344
|
+
formResult.value = errors
|
|
345
|
+
? `校验失败:${Object.values(errors).map((error) => error.message).join(';')}`
|
|
346
|
+
: '校验通过';
|
|
347
|
+
};
|
|
348
|
+
const handleFormReset = () => {
|
|
349
|
+
formRef.value!.resetFields();
|
|
350
|
+
formResult.value = '已重置';
|
|
351
|
+
};
|
|
352
|
+
</script>
|
|
353
|
+
<template>
|
|
354
|
+
<Form ref="formRef" :model="formModel">
|
|
355
|
+
<FormItem field="date" label="交付日期" required feedback>
|
|
356
|
+
<DatePicker v-model="formModel.date" allow-clear />
|
|
357
|
+
</FormItem>
|
|
358
|
+
<FormItem field="range" label="周期">
|
|
359
|
+
<RangePicker v-model="formModel.range" />
|
|
360
|
+
</FormItem>
|
|
361
|
+
<FormItem>
|
|
362
|
+
<Space>
|
|
363
|
+
<Button type="primary" @click="handleFormValidate">校验</Button>
|
|
364
|
+
<Button @click="handleFormReset">重置</Button>
|
|
365
|
+
</Space>
|
|
366
|
+
</FormItem>
|
|
367
|
+
</Form>
|
|
368
|
+
<p role="status">{{ formResult }}</p>
|
|
369
|
+
</template>
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### 键盘导航与焦点
|
|
373
|
+
|
|
374
|
+
日历只保留一个日期格的 Tab 停靠点。Home / End 到当前网格行首尾;PageUp / PageDown 翻页,日期模式加 Shift 翻年。月、年、季度模式按各自网格移动。方向键跳过禁用日期,不提交值;Enter 执行选择。范围模式可连续选择两端,Tab 正常切换两个输入框;Esc 或完成选择后焦点返回输入框,Tab 离开面板不会形成焦点陷阱。
|
|
375
|
+
|
|
376
|
+
原生 `id`、`name`、ARIA 和输入事件透传到真实输入;范围首端使用给定 ID,末端使用 `ID-end`。Form 自动关联标签、帮助及校验错误,独立使用时可设置 `aria-label`。
|
|
377
|
+
|
|
378
|
+
```vue
|
|
379
|
+
<script setup lang="ts">
|
|
380
|
+
import 'x-next/style.css';
|
|
381
|
+
import { DatePicker } from 'x-next';
|
|
382
|
+
import { ref } from 'vue';
|
|
383
|
+
const date = ref('2026-09-10');
|
|
384
|
+
const range = ref(['2026-09-10', '2026-09-15']);
|
|
385
|
+
const log = ref('等待选择');
|
|
386
|
+
const disabledDate = (date: Date) => [0, 6].includes(date.getDay());
|
|
387
|
+
const onChange = (value: import('x-next').DatePickerModelValue) => { log.value = `change: ${value || '空'}`; };
|
|
388
|
+
import type { HTMLAttributes } from 'vue';
|
|
389
|
+
const nativeAttrs1 = { "aria-label": "预约日期" } satisfies HTMLAttributes;
|
|
390
|
+
const nativeAttrs2 = { "aria-label": "预约日期范围" } satisfies HTMLAttributes;
|
|
391
|
+
</script>
|
|
392
|
+
<template>
|
|
393
|
+
<DatePicker v-bind="nativeAttrs1" v-model="date" :disabled-date="disabledDate" @change="onChange" />
|
|
394
|
+
<DatePicker v-bind="nativeAttrs2" v-model="range" type="date-range" />
|
|
395
|
+
<p>{{ log }}</p>
|
|
396
|
+
</template>
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### 交互说明
|
|
400
|
+
|
|
401
|
+
- `showTime` 仅在日期和日期范围模式生效,默认格式为 `YYYY-MM-DD HH:mm:ss`,选择后需要点击“确定”提交。
|
|
402
|
+
- `showLunar` 仅影响日期格辅助展示,不改变 `modelValue`、`format`、范围排序或禁用逻辑;内置数据来自香港天文台 1901-2100 年公历 / 农历对照表,超出范围时默认不展示。
|
|
403
|
+
- 非法手动输入不会提交新值;按 Enter 或失焦时会尝试按 `format` 解析。
|
|
404
|
+
- 普通范围选择会在选择结束值后自动排序并提交;开启 `showTime` 后需要点击“确定”提交。
|
|
405
|
+
- `valueFormat="timestamp"` 会让绑定值和事件值返回时间戳。
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
返回 [AI 索引](../index.md)。先查本页与 [本地 API](./date-picker-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
|
+
# Dialog 完整公开 API
|
|
3
|
+
|
|
4
|
+
适用版本:x-next@1.14.0;来源指纹:`014984639d816a2c7e25eb22690c586b0b2e8efba6846bec8a4e424db41a09e9`。
|
|
5
|
+
|
|
6
|
+
从同版本构建的公开声明、运行时 props/emits 和显式 expose 生成。运行时导入始终使用 `x-next`,声明路径仅作定位。插槽类型未细化时,具体槽名与作用域见本地用法示例。
|
|
7
|
+
|
|
8
|
+
## Dialog API
|
|
9
|
+
|
|
10
|
+
公开声明:`dist/components/dialog/use.d.ts`。
|
|
11
|
+
|
|
12
|
+
### 服务调用
|
|
13
|
+
|
|
14
|
+
| 签名 |
|
|
15
|
+
| --- |
|
|
16
|
+
| (options: DialogOptions): DialogReturn |
|
|
17
|
+
|
|
18
|
+
### 服务成员
|
|
19
|
+
|
|
20
|
+
| 名称 | 类型 |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| destroyAll | () => void |
|
|
23
|
+
|
|
24
|
+
### 关联类型定义
|
|
25
|
+
|
|
26
|
+
以下摘自本组件族声明,供查阅嵌套配置;运行时和值类型均以根入口可导出项为准。
|
|
27
|
+
|
|
28
|
+
```typescript-reference
|
|
29
|
+
type DialogBeforeAction = () => boolean | Promise<boolean>;
|
|
30
|
+
|
|
31
|
+
type DialogContent = string | number | VNode | RenderFunction;
|
|
32
|
+
|
|
33
|
+
type DialogRenderResult = string | number | VNode | VNode[] | null | undefined;
|
|
34
|
+
|
|
35
|
+
interface DialogOptions {
|
|
36
|
+
title?: DialogContent;
|
|
37
|
+
content?: DialogContent;
|
|
38
|
+
footer?: boolean | VNode | ((scoped: DialogFooterScoped) => DialogRenderResult);
|
|
39
|
+
okText?: string;
|
|
40
|
+
cancelText?: string;
|
|
41
|
+
mask?: boolean;
|
|
42
|
+
maskToClose?: boolean;
|
|
43
|
+
onOk?: (e: Event) => void;
|
|
44
|
+
beforeOnOk?: DialogBeforeAction;
|
|
45
|
+
onCancel?: (e: Event) => void;
|
|
46
|
+
beforeOnCancel?: DialogBeforeAction;
|
|
47
|
+
width?: number | string;
|
|
48
|
+
height?: number | string;
|
|
49
|
+
top?: number | string;
|
|
50
|
+
center?: boolean;
|
|
51
|
+
renderTo?: string | HTMLElement;
|
|
52
|
+
hideCancel?: boolean;
|
|
53
|
+
hideOk?: boolean;
|
|
54
|
+
popupClass?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type DialogFooterAction = 'cancel' | 'ok';
|
|
58
|
+
|
|
59
|
+
interface DialogFooterScoped {
|
|
60
|
+
cancel(): void;
|
|
61
|
+
ok(): void;
|
|
62
|
+
loadingObj?: {
|
|
63
|
+
ok: boolean;
|
|
64
|
+
cancel: boolean;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface DialogReturn {
|
|
69
|
+
close(): void;
|
|
70
|
+
update(options: Partial<DialogOptions>): void;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface DialogCaller {
|
|
74
|
+
(options: DialogOptions): DialogReturn;
|
|
75
|
+
destroyAll(): void;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## DialogComponent API
|
|
81
|
+
|
|
82
|
+
公开声明:`dist/components/dialog/index.d.ts`。 类型中的 undefined 表示可省略;原始 prop 默认值不等于继承配置或服务默认值。
|
|
83
|
+
|
|
84
|
+
### Props
|
|
85
|
+
|
|
86
|
+
| 名称 | 用途 | 公开类型 | 必填 | 声明默认值 |
|
|
87
|
+
| --- | --- | --- | --- | --- |
|
|
88
|
+
| renderTo | 见场景用法与类型 | undefined | string | HTMLElement | 否 | "body" |
|
|
89
|
+
| disabled | 见场景用法与类型 | undefined | false | true | 否 | false |
|
|
90
|
+
| modelValue | 见场景用法与类型 | undefined | false | true | 否 | false |
|
|
91
|
+
| top | 见场景用法与类型 | undefined | string | number | 否 | "3vh" |
|
|
92
|
+
| center | 见场景用法与类型 | undefined | false | true | 否 | false |
|
|
93
|
+
| width | 见场景用法与类型 | undefined | string | number | 否 | 0 |
|
|
94
|
+
| height | 见场景用法与类型 | undefined | string | number | 否 | 0 |
|
|
95
|
+
| minWidth | 见场景用法与类型 | undefined | string | number | 否 | 0 |
|
|
96
|
+
| minHeight | 见场景用法与类型 | undefined | string | number | 否 | 0 |
|
|
97
|
+
| title | 见场景用法与类型 | undefined | string | 否 | "" |
|
|
98
|
+
| mask | 见场景用法与类型 | undefined | false | true | 否 | true |
|
|
99
|
+
| destroyOnClosed | 见场景用法与类型 | undefined | false | true | 否 | true |
|
|
100
|
+
| onBeforeCancel | 见场景用法与类型 | undefined | Function | 否 | 未声明 |
|
|
101
|
+
| maskToClose | 见场景用法与类型 | undefined | false | true | 否 | true |
|
|
102
|
+
| escToClose | 见场景用法与类型 | undefined | false | true | 否 | true |
|
|
103
|
+
| fullscreen | 见场景用法与类型 | undefined | false | true | 否 | false |
|
|
104
|
+
| messageBox | 见场景用法与类型 | undefined | false | true | 否 | false |
|
|
105
|
+
| popupClass | 见场景用法与类型 | undefined | string | 否 | undefined |
|
|
106
|
+
| showClose | 见场景用法与类型 | undefined | false | true | 否 | true |
|
|
107
|
+
| showHeaderBottomLine | 见场景用法与类型 | undefined | false | true | 否 | false |
|
|
108
|
+
| hideFooter | 见场景用法与类型 | undefined | false | true | 否 | false |
|
|
109
|
+
|
|
110
|
+
### Events
|
|
111
|
+
|
|
112
|
+
| 事件 | 用途 | 监听器签名(即事件参数) |
|
|
113
|
+
| --- | --- | --- |
|
|
114
|
+
| closed | 见场景用法与类型 | undefined | (...args: any[]) => any |
|
|
115
|
+
| close | 见场景用法与类型 | undefined | (...args: any[]) => any |
|
|
116
|
+
| open | 见场景用法与类型 | undefined | (...args: any[]) => any |
|
|
117
|
+
| opened | 见场景用法与类型 | undefined | (...args: any[]) => any |
|
|
118
|
+
| update:modelValue | 见场景用法与类型 | undefined | (...args: any[]) => any |
|
|
119
|
+
| beforeCancel | 见场景用法与类型 | undefined | Function |
|
|
120
|
+
|
|
121
|
+
### Slots
|
|
122
|
+
|
|
123
|
+
| 名称 | 用途 | 公开类型 |
|
|
124
|
+
| --- | --- | --- |
|
|
125
|
+
| title | 见场景用法与类型 | any |
|
|
126
|
+
| default | 见场景用法与类型 | any |
|
|
127
|
+
| footer | 见场景用法与类型 | any |
|
|
128
|
+
|
|
129
|
+
### 实例方法
|
|
130
|
+
|
|
131
|
+
没有检索到显式 expose 或 Options API methods 的公开方法;不把 setup 内部函数当成稳定实例 API。
|
|
132
|
+
|
|
133
|
+
### 关联类型定义
|
|
134
|
+
|
|
135
|
+
以下摘自本组件族声明,供查阅嵌套配置;运行时和值类型均以根入口可导出项为准。
|
|
136
|
+
|
|
137
|
+
```typescript-reference
|
|
138
|
+
type DialogInstance = InstanceType<typeof _Dialog>;
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
返回 [Dialog 用法](./dialog.md)。
|