@cyberpunk-vue/components 1.13.6 → 1.13.8

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.
@@ -1,91 +1,50 @@
1
1
  import { ExtractPropTypes, PropType } from 'vue';
2
- import { Placement } from '@floating-ui/dom';
3
- import { Size } from '@cyberpunk-vue/hooks';
4
- export type PickerType = 'date' | 'dates' | 'week' | 'month' | 'year' | 'daterange' | 'monthrange' | 'yearrange' | 'time' | 'timerange' | 'datetime' | 'datetimerange';
5
- export type PickerSize = Size;
6
- export type PickerShape = 'clip' | 'no-clip' | 'round';
7
- export type PickerVariant = 'outline' | 'filled' | 'ghost';
8
- export type PickerValueItem = string | number | Date;
9
- export type PickerModelValue = PickerValueItem | PickerValueItem[] | null | undefined;
10
- export type PickerRangeRole = 'start' | 'end';
11
- export interface PickerShortcut {
12
- /** 快捷项显示文本 */
13
- text: string;
14
- /** 快捷项值,可以是静态值或返回值的函数 */
15
- value: PickerModelValue | (() => PickerModelValue);
16
- }
17
- export interface PickerCell {
18
- /** 单元格对应日期 */
2
+ export type DatePickerValue = string | number | Date | null | undefined;
3
+ export type DatePickerViewMode = 'day' | 'month' | 'year';
4
+ export interface DatePickerDayCell {
5
+ /** 单元格日期 */
19
6
  date: Date;
20
- /** 单元格显示文本 */
7
+ /** 展示数字 */
21
8
  label: string;
22
- /** 是否为当前视图范围外的日期 */
23
- outside: boolean;
9
+ /** 是否属于当前月份 */
10
+ currentMonth: boolean;
24
11
  /** 是否为今天 */
25
12
  today: boolean;
26
- /** 是否被选中 */
13
+ /** 是否选中 */
27
14
  selected: boolean;
28
- /** 是否处于范围内 */
29
- inRange: boolean;
30
- /** 是否为范围起点 */
31
- rangeStart: boolean;
32
- /** 是否为范围终点 */
33
- rangeEnd: boolean;
34
15
  /** 是否禁用 */
35
16
  disabled: boolean;
36
17
  }
37
- export type DisabledTimeResolver = (role?: PickerRangeRole) => number[];
38
18
  /**
39
19
  * CpDatePicker 组件 Props 定义
40
20
  *
41
- * @description 赛博朋克风格日期选择器,支持日期、多日期、周、月、年以及日期范围选择。
21
+ * @description 赛博朋克风格日期面板。参考 Vuetify DatePicker 的 header / controls / month grid 分层,年份选择置于左侧,月份置于右侧,更符合中文日期选择习惯。
42
22
  *
43
23
  * @example
44
24
  * ```vue
45
- * <CpDatePicker v-model="date" value-format="YYYY-MM-DD" />
46
- * <CpDatePicker v-model="range" type="daterange" value-format="YYYY-MM-DD" />
25
+ * <CpDatePicker v-model="date" value-format="YYYY-MM-DD" show-adjacent-months />
47
26
  * ```
48
27
  *
49
28
  * @slots
50
- * - `prefix` - 触发器前缀内容
51
- * - `suffix` - 触发器后缀内容
52
- * - `cell` - 自定义日期单元格内容
53
- * - `footer` - 自定义面板底部操作区
29
+ * - `day` - 自定义日期单元格内容
30
+ * - `header` - 自定义顶部标题区
31
+ * - `actions` - 自定义底部操作区
54
32
  *
55
33
  * @exposes
56
- * - `open` - 打开选择器浮层
57
- * - `close` - 关闭选择器浮层
58
- * - `toggle` - 切换选择器浮层
59
- * - `focus` - 聚焦触发器
60
- * - `blur` - 失焦触发器
34
+ * - `goToday` - 跳转并选中今天
35
+ * - `setViewDate` - 设置当前展示年月
61
36
  * @category 表单组件
62
- * @displayName CpDatePicker 日期选择器
37
+ * @displayName CpDatePicker 日期面板
63
38
  */
64
- export declare const pickerProps: {
39
+ export declare const datePickerProps: {
65
40
  /**
66
41
  * 绑定值 (v-model)
67
42
  * @default null
68
43
  */
69
44
  readonly modelValue: {
70
- readonly type: PropType<PickerModelValue>;
45
+ readonly type: PropType<DatePickerValue>;
71
46
  readonly default: null;
72
47
  };
73
- /**
74
- * 选择器类型
75
- * @default 'date'
76
- */
77
- readonly type: {
78
- readonly type: PropType<PickerType>;
79
- readonly default: "date";
80
- };
81
- /**
82
- * 显示格式,例如 `YYYY-MM-DD HH:mm:ss`
83
- * @default 按 type 自动推导
84
- */
85
- readonly format: {
86
- readonly type: StringConstructor;
87
- readonly default: "";
88
- };
89
48
  /**
90
49
  * 输出值格式。为空时输出 Date;传入 `timestamp` 时输出时间戳。
91
50
  * @default ''
@@ -95,370 +54,59 @@ export declare const pickerProps: {
95
54
  readonly default: "";
96
55
  };
97
56
  /**
98
- * 占位文本
99
- * @default ''
100
- */
101
- readonly placeholder: {
102
- readonly type: StringConstructor;
103
- readonly default: "";
104
- };
105
- /**
106
- * 范围起始占位文本
107
- * @default '开始'
108
- */
109
- readonly startPlaceholder: {
110
- readonly type: StringConstructor;
111
- readonly default: "开始";
112
- };
113
- /**
114
- * 范围结束占位文本
115
- * @default '结束'
116
- */
117
- readonly endPlaceholder: {
118
- readonly type: StringConstructor;
119
- readonly default: "结束";
120
- };
121
- /**
122
- * 范围分隔符
123
- * @default ' - '
57
+ * 标题文本
58
+ * @default '选择日期'
124
59
  */
125
- readonly rangeSeparator: {
60
+ readonly title: {
126
61
  readonly type: StringConstructor;
127
- readonly default: " - ";
62
+ readonly default: "选择日期";
128
63
  };
129
64
  /**
130
- * 是否禁用
131
- * @default false
132
- */
133
- readonly disabled: {
134
- readonly type: BooleanConstructor;
135
- readonly default: false;
136
- };
137
- /**
138
- * 是否只读
139
- * @default false
140
- */
141
- readonly readonly: {
142
- readonly type: BooleanConstructor;
143
- readonly default: false;
144
- };
145
- /**
146
- * 是否允许直接输入
147
- * @default false
148
- */
149
- readonly editable: {
150
- readonly type: BooleanConstructor;
151
- readonly default: false;
152
- };
153
- /**
154
- * 是否可清空
65
+ * 是否显示相邻月份日期
155
66
  * @default true
156
67
  */
157
- readonly clearable: {
68
+ readonly showAdjacentMonths: {
158
69
  readonly type: BooleanConstructor;
159
70
  readonly default: true;
160
71
  };
161
72
  /**
162
- * 是否显示确认按钮。未设置时范围、时间和日期时间类型默认需要确认。
163
- * @default undefined
164
- */
165
- readonly confirm: {
166
- readonly type: PropType<boolean | undefined>;
167
- readonly default: undefined;
168
- };
169
- /**
170
- * 组件尺寸
171
- * @default 'md'
73
+ * 初始视图模式
74
+ * @default 'day'
172
75
  */
173
- readonly size: {
174
- readonly type: PropType<PickerSize>;
175
- readonly default: "md";
176
- };
177
- /**
178
- * 形状模式
179
- * @default 'clip'
180
- */
181
- readonly shape: {
182
- readonly type: PropType<PickerShape>;
183
- readonly default: "clip";
184
- };
185
- /**
186
- * 视觉变体
187
- * @default 'outline'
188
- */
189
- readonly variant: {
190
- readonly type: PropType<PickerVariant>;
191
- readonly default: "outline";
192
- };
193
- /**
194
- * 自定义主题色
195
- * @default ''
196
- */
197
- readonly color: {
198
- readonly type: StringConstructor;
199
- readonly default: "";
200
- };
201
- /**
202
- * 未激活边框颜色
203
- * @default ''
204
- */
205
- readonly inactiveColor: {
206
- readonly type: StringConstructor;
207
- readonly default: "";
208
- };
209
- /**
210
- * Placeholder 颜色
211
- * @default ''
212
- */
213
- readonly placeholderColor: {
214
- readonly type: StringConstructor;
215
- readonly default: "";
216
- };
217
- /**
218
- * 触发器宽度
219
- * @default ''
220
- */
221
- readonly width: {
222
- readonly type: PropType<string | number>;
223
- readonly default: "";
224
- };
225
- /**
226
- * 弹出位置
227
- * @default 'bottom-start'
228
- */
229
- readonly placement: {
230
- readonly type: PropType<Placement>;
231
- readonly default: "bottom-start";
232
- };
233
- /**
234
- * Teleport 目标
235
- * @default 'body'
236
- */
237
- readonly teleportTo: {
238
- readonly type: PropType<string | HTMLElement>;
239
- readonly default: "body";
240
- };
241
- /**
242
- * 禁用日期判断函数
243
- */
244
- readonly disabledDate: {
245
- readonly type: PropType<(date: Date) => boolean>;
246
- readonly default: undefined;
247
- };
248
- /**
249
- * 禁用小时列表
250
- */
251
- readonly disabledHours: {
252
- readonly type: PropType<DisabledTimeResolver>;
253
- readonly default: undefined;
254
- };
255
- /**
256
- * 禁用分钟列表
257
- */
258
- readonly disabledMinutes: {
259
- readonly type: PropType<DisabledTimeResolver>;
260
- readonly default: undefined;
261
- };
262
- /**
263
- * 禁用秒列表
264
- */
265
- readonly disabledSeconds: {
266
- readonly type: PropType<DisabledTimeResolver>;
267
- readonly default: undefined;
268
- };
269
- /**
270
- * 小时步长
271
- * @default 1
272
- */
273
- readonly hourStep: {
274
- readonly type: NumberConstructor;
275
- readonly default: 1;
276
- };
277
- /**
278
- * 分钟步长
279
- * @default 1
280
- */
281
- readonly minuteStep: {
282
- readonly type: NumberConstructor;
283
- readonly default: 1;
284
- };
285
- /**
286
- * 秒步长
287
- * @default 1
288
- */
289
- readonly secondStep: {
290
- readonly type: NumberConstructor;
291
- readonly default: 1;
292
- };
293
- /**
294
- * 是否显示秒
295
- * @default true
296
- */
297
- readonly showSeconds: {
298
- readonly type: BooleanConstructor;
299
- readonly default: true;
300
- };
301
- /**
302
- * 快捷选项
303
- * @default []
304
- */
305
- readonly shortcuts: {
306
- readonly type: PropType<PickerShortcut[]>;
307
- readonly default: () => never[];
76
+ readonly viewMode: {
77
+ readonly type: PropType<DatePickerViewMode>;
78
+ readonly default: "day";
308
79
  };
309
80
  /**
310
81
  * 默认展示日期
82
+ * @default undefined
311
83
  */
312
84
  readonly defaultValue: {
313
- readonly type: PropType<PickerValueItem>;
85
+ readonly type: PropType<Exclude<DatePickerValue, null | undefined>>;
314
86
  readonly default: undefined;
315
87
  };
316
88
  /**
317
- * 默认时间,支持 `HH:mm:ss` 或范围数组
89
+ * 最小可选日期
318
90
  * @default undefined
319
91
  */
320
- readonly defaultTime: {
321
- readonly type: PropType<string | [string, string]>;
92
+ readonly min: {
93
+ readonly type: PropType<Exclude<DatePickerValue, null | undefined>>;
322
94
  readonly default: undefined;
323
95
  };
324
96
  /**
325
- * 范围面板是否解除联动
326
- * @default false
327
- */
328
- readonly unlinkPanels: {
329
- readonly type: BooleanConstructor;
330
- readonly default: false;
331
- };
332
- };
333
- export type PickerProps = ExtractPropTypes<typeof pickerProps>;
334
- export declare const datePickerProps: {
335
- /**
336
- * 绑定值 (v-model)
337
- * @default null
338
- */
339
- readonly modelValue: {
340
- readonly type: PropType<PickerModelValue>;
341
- readonly default: null;
342
- };
343
- /**
344
- * 选择器类型
345
- * @default 'date'
346
- */
347
- readonly type: {
348
- readonly type: PropType<PickerType>;
349
- readonly default: "date";
350
- };
351
- /**
352
- * 显示格式,例如 `YYYY-MM-DD HH:mm:ss`
353
- * @default 按 type 自动推导
354
- */
355
- readonly format: {
356
- readonly type: StringConstructor;
357
- readonly default: "";
358
- };
359
- /**
360
- * 输出值格式。为空时输出 Date;传入 `timestamp` 时输出时间戳。
361
- * @default ''
362
- */
363
- readonly valueFormat: {
364
- readonly type: StringConstructor;
365
- readonly default: "";
366
- };
367
- /**
368
- * 占位文本
369
- * @default ''
370
- */
371
- readonly placeholder: {
372
- readonly type: StringConstructor;
373
- readonly default: "";
374
- };
375
- /**
376
- * 范围起始占位文本
377
- * @default '开始'
378
- */
379
- readonly startPlaceholder: {
380
- readonly type: StringConstructor;
381
- readonly default: "开始";
382
- };
383
- /**
384
- * 范围结束占位文本
385
- * @default '结束'
386
- */
387
- readonly endPlaceholder: {
388
- readonly type: StringConstructor;
389
- readonly default: "结束";
390
- };
391
- /**
392
- * 范围分隔符
393
- * @default ' - '
394
- */
395
- readonly rangeSeparator: {
396
- readonly type: StringConstructor;
397
- readonly default: " - ";
398
- };
399
- /**
400
- * 是否禁用
401
- * @default false
402
- */
403
- readonly disabled: {
404
- readonly type: BooleanConstructor;
405
- readonly default: false;
406
- };
407
- /**
408
- * 是否只读
409
- * @default false
410
- */
411
- readonly readonly: {
412
- readonly type: BooleanConstructor;
413
- readonly default: false;
414
- };
415
- /**
416
- * 是否允许直接输入
417
- * @default false
418
- */
419
- readonly editable: {
420
- readonly type: BooleanConstructor;
421
- readonly default: false;
422
- };
423
- /**
424
- * 是否可清空
425
- * @default true
426
- */
427
- readonly clearable: {
428
- readonly type: BooleanConstructor;
429
- readonly default: true;
430
- };
431
- /**
432
- * 是否显示确认按钮。未设置时范围、时间和日期时间类型默认需要确认。
97
+ * 最大可选日期
433
98
  * @default undefined
434
99
  */
435
- readonly confirm: {
436
- readonly type: PropType<boolean | undefined>;
100
+ readonly max: {
101
+ readonly type: PropType<Exclude<DatePickerValue, null | undefined>>;
437
102
  readonly default: undefined;
438
103
  };
439
104
  /**
440
- * 组件尺寸
441
- * @default 'md'
442
- */
443
- readonly size: {
444
- readonly type: PropType<PickerSize>;
445
- readonly default: "md";
446
- };
447
- /**
448
- * 形状模式
449
- * @default 'clip'
450
- */
451
- readonly shape: {
452
- readonly type: PropType<PickerShape>;
453
- readonly default: "clip";
454
- };
455
- /**
456
- * 视觉变体
457
- * @default 'outline'
105
+ * 禁用日期判断函数
458
106
  */
459
- readonly variant: {
460
- readonly type: PropType<PickerVariant>;
461
- readonly default: "outline";
107
+ readonly disabledDate: {
108
+ readonly type: PropType<(date: Date) => boolean>;
109
+ readonly default: undefined;
462
110
  };
463
111
  /**
464
112
  * 自定义主题色
@@ -469,189 +117,38 @@ export declare const datePickerProps: {
469
117
  readonly default: "";
470
118
  };
471
119
  /**
472
- * 未激活边框颜色
473
- * @default ''
474
- */
475
- readonly inactiveColor: {
476
- readonly type: StringConstructor;
477
- readonly default: "";
478
- };
479
- /**
480
- * Placeholder 颜色
481
- * @default ''
482
- */
483
- readonly placeholderColor: {
484
- readonly type: StringConstructor;
485
- readonly default: "";
486
- };
487
- /**
488
- * 触发器宽度
489
- * @default ''
490
- */
491
- readonly width: {
492
- readonly type: PropType<string | number>;
493
- readonly default: "";
494
- };
495
- /**
496
- * 弹出位置
497
- * @default 'bottom-start'
498
- */
499
- readonly placement: {
500
- readonly type: PropType<Placement>;
501
- readonly default: "bottom-start";
502
- };
503
- /**
504
- * Teleport 目标
505
- * @default 'body'
506
- */
507
- readonly teleportTo: {
508
- readonly type: PropType<string | HTMLElement>;
509
- readonly default: "body";
510
- };
511
- /**
512
- * 禁用日期判断函数
513
- */
514
- readonly disabledDate: {
515
- readonly type: PropType<(date: Date) => boolean>;
516
- readonly default: undefined;
517
- };
518
- /**
519
- * 禁用小时列表
520
- */
521
- readonly disabledHours: {
522
- readonly type: PropType<DisabledTimeResolver>;
523
- readonly default: undefined;
524
- };
525
- /**
526
- * 禁用分钟列表
527
- */
528
- readonly disabledMinutes: {
529
- readonly type: PropType<DisabledTimeResolver>;
530
- readonly default: undefined;
531
- };
532
- /**
533
- * 禁用秒列表
534
- */
535
- readonly disabledSeconds: {
536
- readonly type: PropType<DisabledTimeResolver>;
537
- readonly default: undefined;
538
- };
539
- /**
540
- * 小时步长
541
- * @default 1
542
- */
543
- readonly hourStep: {
544
- readonly type: NumberConstructor;
545
- readonly default: 1;
546
- };
547
- /**
548
- * 分钟步长
549
- * @default 1
550
- */
551
- readonly minuteStep: {
552
- readonly type: NumberConstructor;
553
- readonly default: 1;
554
- };
555
- /**
556
- * 秒步长
557
- * @default 1
558
- */
559
- readonly secondStep: {
560
- readonly type: NumberConstructor;
561
- readonly default: 1;
562
- };
563
- /**
564
- * 是否显示秒
565
- * @default true
566
- */
567
- readonly showSeconds: {
568
- readonly type: BooleanConstructor;
569
- readonly default: true;
570
- };
571
- /**
572
- * 快捷选项
573
- * @default []
574
- */
575
- readonly shortcuts: {
576
- readonly type: PropType<PickerShortcut[]>;
577
- readonly default: () => never[];
578
- };
579
- /**
580
- * 默认展示日期
581
- */
582
- readonly defaultValue: {
583
- readonly type: PropType<PickerValueItem>;
584
- readonly default: undefined;
585
- };
586
- /**
587
- * 默认时间,支持 `HH:mm:ss` 或范围数组
588
- * @default undefined
589
- */
590
- readonly defaultTime: {
591
- readonly type: PropType<string | [string, string]>;
592
- readonly default: undefined;
593
- };
594
- /**
595
- * 范围面板是否解除联动
120
+ * 是否禁用整个面板
596
121
  * @default false
597
122
  */
598
- readonly unlinkPanels: {
123
+ readonly disabled: {
599
124
  readonly type: BooleanConstructor;
600
125
  readonly default: false;
601
126
  };
602
127
  };
603
- export type DatePickerProps = PickerProps;
604
- export declare const pickerEmits: {
605
- /**
606
- * v-model 更新事件
607
- */
608
- 'update:modelValue': (_value: PickerModelValue) => boolean;
609
- /**
610
- * 值变化事件
611
- */
612
- change: (_value: PickerModelValue) => boolean;
613
- /**
614
- * 清空事件
615
- */
616
- clear: () => boolean;
617
- /**
618
- * 聚焦事件
619
- */
620
- focus: (event?: FocusEvent) => boolean;
621
- /**
622
- * 失焦事件
623
- */
624
- blur: (event?: FocusEvent) => boolean;
625
- /**
626
- * 浮层显示状态变化
627
- */
628
- visibleChange: (visible: boolean) => boolean;
629
- };
630
- export type PickerEmits = typeof pickerEmits;
128
+ export type DatePickerProps = ExtractPropTypes<typeof datePickerProps>;
129
+ /**
130
+ * CpDatePicker 组件事件定义
131
+ */
631
132
  export declare const datePickerEmits: {
632
133
  /**
633
134
  * v-model 更新事件
634
135
  */
635
- 'update:modelValue': (_value: PickerModelValue) => boolean;
136
+ 'update:modelValue': (_value: DatePickerValue) => boolean;
636
137
  /**
637
138
  * 值变化事件
638
139
  */
639
- change: (_value: PickerModelValue) => boolean;
640
- /**
641
- * 清空事件
642
- */
643
- clear: () => boolean;
140
+ change: (_value: DatePickerValue) => boolean;
644
141
  /**
645
- * 聚焦事件
142
+ * 展示月份变化事件
646
143
  */
647
- focus: (event?: FocusEvent) => boolean;
144
+ 'update:month': (month: number) => boolean;
648
145
  /**
649
- * 失焦事件
146
+ * 展示年份变化事件
650
147
  */
651
- blur: (event?: FocusEvent) => boolean;
148
+ 'update:year': (year: number) => boolean;
652
149
  /**
653
- * 浮层显示状态变化
150
+ * 视图模式变化事件
654
151
  */
655
- visibleChange: (visible: boolean) => boolean;
152
+ 'update:viewMode': (mode: DatePickerViewMode) => boolean;
656
153
  };
657
- export type DatePickerEmits = PickerEmits;
154
+ export type DatePickerEmits = typeof datePickerEmits;