@ysgroup/ui 0.1.55 → 0.1.56

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ysgroup/ui",
3
- "version": "0.1.55",
3
+ "version": "0.1.56",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "peerDependencies": {
13
13
  "@ysgroup/contracts": ">=0.1.50",
14
- "@ysgroup/core": ">=0.1.30",
14
+ "@ysgroup/core": ">=0.1.31",
15
15
  "@ysgroup/theme": ">=0.3.3",
16
16
  "element-plus": ">=2.9",
17
17
  "vue": ">=3.5"
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@ysgroup/contracts": "^0.1.51",
29
- "@ysgroup/core": "^0.1.30",
29
+ "@ysgroup/core": "^0.1.31",
30
30
  "@ysgroup/theme": "^0.3.3",
31
31
  "docx-preview": "^0.4.1"
32
32
  }
@@ -0,0 +1,715 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * 月历:法定节假日(休、班、节日名)、交易日、今天、选中日,可放事件条;迷你模式用于侧栏或日期概览。
4
+ *
5
+ * - 日期信息(days)由服务端 ys_base.calendar 下发,组件只显示,不自己按周一到周五猜;
6
+ * 某天 covered 为 false 表示这一年还没有放假安排,顶部写明、格子不标休班。
7
+ * - v-model 是选中日期,v-model:month 是显示的月份(`YYYY-MM`);翻月后按 ysMonthRange(month) 取这一屏的日期信息。
8
+ * - 键盘:方向键移动一天或一周,PageUp / PageDown 翻月,Home / End 到本周一 / 周日,Enter 或空格选中;跨月自动翻页。
9
+ * - 事件条(events)每格最多 maxEvents 条,其余收成「+N」(触发 more);要完全自定义格子内容用 #day 插槽。
10
+ */
11
+ import { computed, nextTick, ref, watch } from "vue";
12
+ import {
13
+ YS_DAY_KIND_LABELS,
14
+ YS_WEEKDAY_LABELS,
15
+ ysAddDays,
16
+ ysDateTitle,
17
+ ysIsDate,
18
+ ysMonthGrid,
19
+ ysMonthOf,
20
+ ysShiftMonth,
21
+ ysToday,
22
+ ysWeekday,
23
+ type YsCalendarDay,
24
+ type YsMonthCell,
25
+ } from "@ysgroup/core";
26
+
27
+ export interface YsCalendarEvent {
28
+ date: string;
29
+ title: string;
30
+ id?: string | number;
31
+ tone?: "primary" | "success" | "warning" | "danger" | "info";
32
+ }
33
+
34
+ const props = withDefaults(
35
+ defineProps<{
36
+ modelValue?: string;
37
+ month?: string;
38
+ days?: readonly YsCalendarDay[];
39
+ events?: readonly YsCalendarEvent[];
40
+ today?: string;
41
+ loading?: boolean;
42
+ size?: "default" | "small";
43
+ /** 标出交易日:调休上班的周末写「休市」,图例说明交易日规则。 */
44
+ trading?: boolean;
45
+ maxEvents?: number;
46
+ /** 不能选的日期(如非交易日):变淡、点了不选中。 */
47
+ disabledDate?: (date: string, info?: YsCalendarDay) => boolean;
48
+ /** 显示底部图例;默认有日期信息时显示。 */
49
+ legend?: boolean | null;
50
+ }>(),
51
+ {
52
+ modelValue: "",
53
+ month: "",
54
+ days: () => [],
55
+ events: () => [],
56
+ today: "",
57
+ loading: false,
58
+ size: "default",
59
+ trading: false,
60
+ maxEvents: 3,
61
+ disabledDate: undefined,
62
+ legend: null,
63
+ },
64
+ );
65
+
66
+ const emit = defineEmits<{
67
+ "update:modelValue": [date: string];
68
+ "update:month": [month: string];
69
+ select: [date: string, info: YsCalendarDay | undefined];
70
+ more: [date: string];
71
+ }>();
72
+
73
+ const todayText = computed(() => props.today || ysToday());
74
+ const innerMonth = ref(
75
+ props.month || ysMonthOf(props.modelValue || todayText.value),
76
+ );
77
+ watch(
78
+ () => props.month,
79
+ (value) => {
80
+ if (value && value !== innerMonth.value) innerMonth.value = value;
81
+ },
82
+ );
83
+ const shownMonth = computed(() => innerMonth.value);
84
+ const cells = computed(() => ysMonthGrid(shownMonth.value));
85
+ const rows = computed(() =>
86
+ Array.from({ length: 6 }, (_, row) =>
87
+ cells.value.slice(row * 7, row * 7 + 7),
88
+ ),
89
+ );
90
+ const infoMap = computed(
91
+ () => new Map(props.days.map((item) => [item.date, item])),
92
+ );
93
+ const eventMap = computed(() => {
94
+ const map = new Map<string, YsCalendarEvent[]>();
95
+ for (const item of props.events) {
96
+ const list = map.get(item.date);
97
+ if (list) list.push(item);
98
+ else map.set(item.date, [item]);
99
+ }
100
+ return map;
101
+ });
102
+ /** 这一屏里还没有放假安排的年份。 */
103
+ const missingYears = computed(() => {
104
+ const years = new Set<string>();
105
+ for (const cell of cells.value)
106
+ if (infoMap.value.get(cell.date)?.covered === false)
107
+ years.add(cell.date.slice(0, 4));
108
+ return [...years].sort();
109
+ });
110
+ const showLegend = computed(
111
+ () => props.size !== "small" && (props.legend ?? props.days.length > 0),
112
+ );
113
+ const small = computed(() => props.size === "small");
114
+
115
+ function setMonth(month: string) {
116
+ if (!month || month === innerMonth.value) return;
117
+ innerMonth.value = month;
118
+ emit("update:month", month);
119
+ }
120
+
121
+ // ---------- 格子状态 ----------
122
+ function info(date: string): YsCalendarDay | undefined {
123
+ return infoMap.value.get(date);
124
+ }
125
+ function eventsOf(date: string): YsCalendarEvent[] {
126
+ return eventMap.value.get(date) ?? [];
127
+ }
128
+ function covered(date: string): boolean {
129
+ return info(date)?.covered !== false;
130
+ }
131
+ function badge(date: string): "休" | "班" | "" {
132
+ const item = info(date);
133
+ if (!item || item.covered === false) return "";
134
+ if (item.kind === "holiday") return "休";
135
+ if (item.kind === "adjusted") return "班";
136
+ return "";
137
+ }
138
+ function isRest(cell: YsMonthCell): boolean {
139
+ const item = info(cell.date);
140
+ if (item && item.covered !== false)
141
+ return item.kind === "holiday" || item.kind === "weekend";
142
+ return cell.weekday >= 5;
143
+ }
144
+ function disabled(date: string): boolean {
145
+ return Boolean(props.disabledDate?.(date, info(date)));
146
+ }
147
+ function ariaLabel(cell: YsMonthCell): string {
148
+ const item = info(cell.date);
149
+ const parts = [ysDateTitle(cell.date)];
150
+ if (item?.covered === false) parts.push("放假安排还没有");
151
+ else if (item) {
152
+ parts.push(
153
+ item.name
154
+ ? `${YS_DAY_KIND_LABELS[item.kind]} ${item.name}`
155
+ : YS_DAY_KIND_LABELS[item.kind],
156
+ );
157
+ if (props.trading) parts.push(item.trading ? "交易日" : "非交易日");
158
+ }
159
+ if (cell.date === todayText.value) parts.push("今天");
160
+ const count = eventsOf(cell.date).length;
161
+ if (count) parts.push(`${count} 项`);
162
+ if (disabled(cell.date)) parts.push("不可选");
163
+ return parts.join(",");
164
+ }
165
+
166
+ // ---------- 选择与键盘 ----------
167
+ const grid = ref<HTMLElement | null>(null);
168
+ const focusDate = ref(
169
+ ysIsDate(props.modelValue) ? props.modelValue : todayText.value,
170
+ );
171
+ watch(
172
+ () => props.modelValue,
173
+ (value) => {
174
+ if (ysIsDate(value)) focusDate.value = value;
175
+ },
176
+ );
177
+ /** 可以 Tab 进来的那一格:焦点日在本屏就用它,否则用本月 1 日。 */
178
+ const tabDate = computed(() =>
179
+ cells.value.some((cell) => cell.date === focusDate.value)
180
+ ? focusDate.value
181
+ : `${shownMonth.value}-01`,
182
+ );
183
+
184
+ function select(date: string) {
185
+ focusDate.value = date;
186
+ if (!date.startsWith(shownMonth.value)) setMonth(ysMonthOf(date));
187
+ if (disabled(date)) return;
188
+ emit("update:modelValue", date);
189
+ emit("select", date, info(date));
190
+ }
191
+
192
+ function moveFocus(date: string) {
193
+ focusDate.value = date;
194
+ if (!date.startsWith(shownMonth.value)) setMonth(ysMonthOf(date));
195
+ void nextTick(() =>
196
+ grid.value?.querySelector<HTMLElement>(`[data-date="${date}"]`)?.focus(),
197
+ );
198
+ }
199
+
200
+ function onKeydown(event: KeyboardEvent) {
201
+ const current = focusDate.value;
202
+ const weekday = ysWeekday(current);
203
+ const moves: Record<string, () => string> = {
204
+ ArrowLeft: () => ysAddDays(current, -1),
205
+ ArrowRight: () => ysAddDays(current, 1),
206
+ ArrowUp: () => ysAddDays(current, -7),
207
+ ArrowDown: () => ysAddDays(current, 7),
208
+ Home: () => ysAddDays(current, -weekday),
209
+ End: () => ysAddDays(current, 6 - weekday),
210
+ PageUp: () => shiftKeepDay(current, -1),
211
+ PageDown: () => shiftKeepDay(current, 1),
212
+ };
213
+ if (event.key === "Enter" || event.key === " ") {
214
+ event.preventDefault();
215
+ select(current);
216
+ return;
217
+ }
218
+ const move = moves[event.key];
219
+ if (!move) return;
220
+ event.preventDefault();
221
+ moveFocus(move());
222
+ }
223
+
224
+ /** 翻月时保持几号;下个月没有这一天(如 1 月 31 日 → 2 月)就落在月末。 */
225
+ function shiftKeepDay(date: string, delta: number): string {
226
+ const month = ysShiftMonth(ysMonthOf(date), delta);
227
+ let day = Number(date.slice(8));
228
+ while (day > 28 && !ysIsDate(`${month}-${String(day).padStart(2, "0")}`))
229
+ day -= 1;
230
+ return `${month}-${String(day).padStart(2, "0")}`;
231
+ }
232
+
233
+ function goToday() {
234
+ setMonth(ysMonthOf(todayText.value));
235
+ select(todayText.value);
236
+ }
237
+ </script>
238
+
239
+ <template>
240
+ <div class="ys-calendar" :class="{ 'is-small': small }">
241
+ <header class="ys-calendar__head">
242
+ <div class="ys-calendar__nav">
243
+ <el-button
244
+ text
245
+ :size="small ? 'small' : 'default'"
246
+ aria-label="上个月"
247
+ class="ys-calendar__arrow"
248
+ @click="setMonth(ysShiftMonth(shownMonth, -1))"
249
+ >‹</el-button
250
+ >
251
+ <el-date-picker
252
+ :model-value="shownMonth"
253
+ type="month"
254
+ value-format="YYYY-MM"
255
+ format="YYYY 年 M 月"
256
+ :clearable="false"
257
+ :editable="false"
258
+ :size="small ? 'small' : 'default'"
259
+ class="ys-calendar__month"
260
+ aria-label="选择月份"
261
+ @update:model-value="(value: string) => setMonth(value)"
262
+ />
263
+ <el-button
264
+ text
265
+ :size="small ? 'small' : 'default'"
266
+ aria-label="下个月"
267
+ class="ys-calendar__arrow"
268
+ @click="setMonth(ysShiftMonth(shownMonth, 1))"
269
+ >›</el-button
270
+ >
271
+ <el-button :size="small ? 'small' : 'default'" @click="goToday"
272
+ >今天</el-button
273
+ >
274
+ </div>
275
+ <div v-if="$slots.extra" class="ys-calendar__extra">
276
+ <slot name="extra" />
277
+ </div>
278
+ </header>
279
+
280
+ <p
281
+ v-if="missingYears.length && !small"
282
+ class="ys-calendar__missing"
283
+ role="status"
284
+ >
285
+ {{ missingYears.join("、") }} 年的放假安排还没有(国务院办公厅一般在上一年
286
+ 10–11 月发布),这些日期暂不标休班,也不能判断工作日和交易日。
287
+ </p>
288
+
289
+ <div
290
+ ref="grid"
291
+ v-loading="loading"
292
+ class="ys-calendar__grid"
293
+ role="grid"
294
+ :aria-label="`${shownMonth.slice(0, 4)} 年 ${Number(shownMonth.slice(5))} 月`"
295
+ @keydown="onKeydown"
296
+ >
297
+ <div class="ys-calendar__row is-head" role="row">
298
+ <div
299
+ v-for="(label, index) in YS_WEEKDAY_LABELS"
300
+ :key="label"
301
+ class="ys-calendar__weekday"
302
+ :class="{ 'is-weekend': index >= 5 }"
303
+ role="columnheader"
304
+ >
305
+ {{ small ? label : `周${label}` }}
306
+ </div>
307
+ </div>
308
+ <div
309
+ v-for="(row, rowIndex) in rows"
310
+ :key="rowIndex"
311
+ class="ys-calendar__row"
312
+ role="row"
313
+ >
314
+ <div
315
+ v-for="cell in row"
316
+ :key="cell.date"
317
+ class="ys-calendar__cell"
318
+ role="gridcell"
319
+ :data-date="cell.date"
320
+ :tabindex="cell.date === tabDate ? 0 : -1"
321
+ :aria-selected="cell.date === modelValue"
322
+ :aria-disabled="disabled(cell.date) || undefined"
323
+ :aria-label="ariaLabel(cell)"
324
+ :title="small ? ariaLabel(cell) : undefined"
325
+ :class="{
326
+ 'is-outside': !cell.inMonth,
327
+ 'is-today': cell.date === todayText,
328
+ 'is-selected': cell.date === modelValue,
329
+ 'is-rest': isRest(cell),
330
+ 'is-holiday':
331
+ info(cell.date)?.kind === 'holiday' && covered(cell.date),
332
+ 'is-adjusted':
333
+ info(cell.date)?.kind === 'adjusted' && covered(cell.date),
334
+ 'is-uncovered': !covered(cell.date),
335
+ 'is-disabled': disabled(cell.date),
336
+ }"
337
+ @click="select(cell.date)"
338
+ @focus="focusDate = cell.date"
339
+ >
340
+ <slot
341
+ name="day"
342
+ :cell="cell"
343
+ :info="info(cell.date)"
344
+ :events="eventsOf(cell.date)"
345
+ >
346
+ <div class="ys-calendar__top">
347
+ <span class="ys-calendar__date">{{
348
+ Number(cell.date.slice(8))
349
+ }}</span>
350
+ <span
351
+ v-if="badge(cell.date)"
352
+ class="ys-calendar__badge"
353
+ :class="badge(cell.date) === '休' ? 'is-off' : 'is-work'"
354
+ >{{ badge(cell.date) }}</span
355
+ >
356
+ </div>
357
+ <template v-if="!small">
358
+ <div
359
+ v-if="info(cell.date)?.name && covered(cell.date)"
360
+ class="ys-calendar__name"
361
+ >
362
+ {{ info(cell.date)?.name
363
+ }}<template
364
+ v-if="trading && info(cell.date)?.kind === 'adjusted'"
365
+ >
366
+ · 休市</template
367
+ >
368
+ </div>
369
+ <ul v-if="eventsOf(cell.date).length" class="ys-calendar__events">
370
+ <li
371
+ v-for="item in eventsOf(cell.date).slice(0, maxEvents)"
372
+ :key="item.id ?? item.title"
373
+ class="ys-calendar__event"
374
+ :class="`is-${item.tone ?? 'primary'}`"
375
+ :title="item.title"
376
+ >
377
+ {{ item.title }}
378
+ </li>
379
+ <li v-if="eventsOf(cell.date).length > maxEvents">
380
+ <button
381
+ type="button"
382
+ class="ys-calendar__more"
383
+ tabindex="-1"
384
+ @click.stop="emit('more', cell.date)"
385
+ v-text="`+${eventsOf(cell.date).length - maxEvents}`"
386
+ />
387
+ </li>
388
+ </ul>
389
+ </template>
390
+ <span
391
+ v-else-if="eventsOf(cell.date).length"
392
+ class="ys-calendar__dot"
393
+ aria-hidden="true"
394
+ />
395
+ </slot>
396
+ </div>
397
+ </div>
398
+ </div>
399
+
400
+ <footer v-if="showLegend" class="ys-calendar__legend">
401
+ <span><i class="ys-calendar__badge is-off">休</i>放假</span>
402
+ <span><i class="ys-calendar__badge is-work">班</i>调休上班</span>
403
+ <span v-if="trading"
404
+ >交易日:周一到周五且不放假;调休上班的周末交易所休市</span
405
+ >
406
+ <span class="ys-calendar__legend-today">今天</span>
407
+ </footer>
408
+ </div>
409
+ </template>
410
+
411
+ <style scoped>
412
+ .ys-calendar {
413
+ --cal-rest: color-mix(
414
+ in srgb,
415
+ var(--ys-color-success) 82%,
416
+ var(--ys-color-text-1)
417
+ );
418
+ --cal-work: color-mix(
419
+ in srgb,
420
+ var(--ys-color-warning) 80%,
421
+ var(--ys-color-text-1)
422
+ );
423
+ display: flex;
424
+ flex-direction: column;
425
+ gap: 8px;
426
+ min-width: 0;
427
+ }
428
+ .ys-calendar__head {
429
+ display: flex;
430
+ flex-wrap: wrap;
431
+ gap: 8px 12px;
432
+ align-items: center;
433
+ justify-content: space-between;
434
+ }
435
+ .ys-calendar__nav {
436
+ display: flex;
437
+ gap: 4px;
438
+ align-items: center;
439
+ }
440
+ .ys-calendar__arrow {
441
+ width: 28px;
442
+ padding: 0;
443
+ font-size: 18px;
444
+ }
445
+ .ys-calendar__nav :deep(.el-date-editor.ys-calendar__month) {
446
+ width: 128px;
447
+ }
448
+ .ys-calendar.is-small
449
+ .ys-calendar__nav
450
+ :deep(.el-date-editor.ys-calendar__month) {
451
+ width: 112px;
452
+ }
453
+ .ys-calendar__extra {
454
+ display: flex;
455
+ flex-wrap: wrap;
456
+ gap: 8px;
457
+ align-items: center;
458
+ }
459
+ .ys-calendar__missing {
460
+ margin: 0;
461
+ padding: 6px 10px;
462
+ border-left: 3px solid var(--ys-color-warning);
463
+ border-radius: var(--ys-radius-s);
464
+ color: var(--ys-color-text-2);
465
+ background: color-mix(in srgb, var(--ys-color-warning) 8%, transparent);
466
+ font-size: 12px;
467
+ line-height: 1.6;
468
+ }
469
+
470
+ /* 网格 */
471
+ .ys-calendar__grid {
472
+ display: flex;
473
+ flex-direction: column;
474
+ border: 1px solid var(--ys-color-border);
475
+ border-radius: var(--ys-radius-m);
476
+ overflow: hidden;
477
+ background: var(--ys-color-bg-elevated);
478
+ }
479
+ .ys-calendar__row {
480
+ display: grid;
481
+ flex: 1;
482
+ grid-template-columns: repeat(7, minmax(0, 1fr));
483
+ }
484
+ .ys-calendar__row + .ys-calendar__row {
485
+ border-top: 1px solid var(--ys-color-border);
486
+ }
487
+ .ys-calendar__row.is-head {
488
+ flex: none;
489
+ background: var(--ys-color-bg);
490
+ }
491
+ .ys-calendar__weekday {
492
+ padding: 6px 8px;
493
+ color: var(--ys-color-text-2);
494
+ font-size: 12px;
495
+ font-weight: 600;
496
+ }
497
+ .ys-calendar__weekday.is-weekend {
498
+ color: var(--cal-rest);
499
+ }
500
+ .ys-calendar__cell {
501
+ position: relative;
502
+ display: flex;
503
+ flex-direction: column;
504
+ gap: 2px;
505
+ min-width: 0;
506
+ min-height: 92px;
507
+ padding: 6px;
508
+ cursor: pointer;
509
+ outline: none;
510
+ transition: background-color 0.12s ease;
511
+ }
512
+ .ys-calendar__cell + .ys-calendar__cell {
513
+ border-left: 1px solid var(--ys-color-border);
514
+ }
515
+ .ys-calendar__cell:hover {
516
+ background: color-mix(in srgb, var(--ys-color-primary) 5%, transparent);
517
+ }
518
+ .ys-calendar__cell:focus-visible {
519
+ box-shadow: inset 0 0 0 2px var(--ys-color-primary);
520
+ }
521
+ .ys-calendar__cell.is-rest:not(.is-selected) {
522
+ background: color-mix(in srgb, var(--ys-color-text-3) 4%, transparent);
523
+ }
524
+ .ys-calendar__cell.is-holiday:not(.is-selected) {
525
+ background: color-mix(in srgb, var(--ys-color-success) 7%, transparent);
526
+ }
527
+ .ys-calendar__cell.is-adjusted:not(.is-selected) {
528
+ background: color-mix(in srgb, var(--ys-color-warning) 7%, transparent);
529
+ }
530
+ .ys-calendar__cell.is-selected {
531
+ background: color-mix(in srgb, var(--ys-color-primary) 11%, transparent);
532
+ box-shadow: inset 0 0 0 1px
533
+ color-mix(in srgb, var(--ys-color-primary) 55%, transparent);
534
+ }
535
+ .ys-calendar__cell.is-outside > * {
536
+ opacity: 0.42;
537
+ }
538
+ .ys-calendar__cell.is-disabled {
539
+ cursor: not-allowed;
540
+ }
541
+ .ys-calendar__cell.is-disabled > * {
542
+ opacity: 0.38;
543
+ }
544
+ .ys-calendar__top {
545
+ display: flex;
546
+ gap: 4px;
547
+ align-items: center;
548
+ justify-content: space-between;
549
+ }
550
+ .ys-calendar__date {
551
+ display: inline-flex;
552
+ align-items: center;
553
+ justify-content: center;
554
+ min-width: 24px;
555
+ height: 24px;
556
+ padding: 0 4px;
557
+ border-radius: 999px;
558
+ color: var(--ys-color-text-1);
559
+ font-size: 13px;
560
+ font-variant-numeric: tabular-nums;
561
+ font-weight: 600;
562
+ }
563
+ .ys-calendar__cell.is-rest .ys-calendar__date {
564
+ color: var(--cal-rest);
565
+ }
566
+ .ys-calendar__cell.is-uncovered .ys-calendar__date {
567
+ text-decoration: underline dotted var(--ys-color-text-3);
568
+ text-underline-offset: 3px;
569
+ }
570
+ .ys-calendar__cell.is-today .ys-calendar__date {
571
+ color: var(--ys-color-on-solid);
572
+ background: var(--ys-color-primary);
573
+ }
574
+ .ys-calendar__badge {
575
+ display: inline-flex;
576
+ align-items: center;
577
+ justify-content: center;
578
+ width: 18px;
579
+ height: 18px;
580
+ border-radius: var(--ys-radius-s);
581
+ font-size: 11px;
582
+ font-style: normal;
583
+ font-weight: 600;
584
+ line-height: 1;
585
+ }
586
+ .ys-calendar__badge.is-off {
587
+ color: var(--cal-rest);
588
+ background: color-mix(in srgb, var(--ys-color-success) 16%, transparent);
589
+ }
590
+ .ys-calendar__badge.is-work {
591
+ color: var(--cal-work);
592
+ background: color-mix(in srgb, var(--ys-color-warning) 18%, transparent);
593
+ }
594
+ .ys-calendar__name {
595
+ overflow: hidden;
596
+ color: var(--cal-rest);
597
+ font-size: 11px;
598
+ line-height: 1.5;
599
+ white-space: nowrap;
600
+ text-overflow: ellipsis;
601
+ }
602
+ .ys-calendar__cell.is-adjusted .ys-calendar__name {
603
+ color: var(--cal-work);
604
+ }
605
+ .ys-calendar__events {
606
+ display: flex;
607
+ flex-direction: column;
608
+ gap: 2px;
609
+ min-width: 0;
610
+ margin: 2px 0 0;
611
+ padding: 0;
612
+ list-style: none;
613
+ }
614
+ .ys-calendar__event {
615
+ --tone: var(--ys-color-primary);
616
+ overflow: hidden;
617
+ padding: 1px 6px;
618
+ border-left: 3px solid var(--tone);
619
+ border-radius: var(--ys-radius-s);
620
+ color: var(--ys-color-text-1);
621
+ background: color-mix(in srgb, var(--tone) 10%, transparent);
622
+ font-size: 12px;
623
+ line-height: 18px;
624
+ white-space: nowrap;
625
+ text-overflow: ellipsis;
626
+ }
627
+ .ys-calendar__event.is-success {
628
+ --tone: var(--ys-color-success);
629
+ }
630
+ .ys-calendar__event.is-warning {
631
+ --tone: var(--ys-color-warning);
632
+ }
633
+ .ys-calendar__event.is-danger {
634
+ --tone: var(--ys-color-danger);
635
+ }
636
+ .ys-calendar__event.is-info {
637
+ --tone: var(--ys-color-text-3);
638
+ }
639
+ .ys-calendar__more {
640
+ padding: 0 6px;
641
+ border: 0;
642
+ border-radius: var(--ys-radius-s);
643
+ color: var(--ys-color-primary);
644
+ background: none;
645
+ font: inherit;
646
+ font-size: 12px;
647
+ line-height: 18px;
648
+ cursor: pointer;
649
+ }
650
+ .ys-calendar__more:hover {
651
+ background: color-mix(in srgb, var(--ys-color-primary) 10%, transparent);
652
+ }
653
+ .ys-calendar__legend {
654
+ display: flex;
655
+ flex-wrap: wrap;
656
+ gap: 4px 16px;
657
+ align-items: center;
658
+ color: var(--ys-color-text-3);
659
+ font-size: 12px;
660
+ }
661
+ .ys-calendar__legend > span {
662
+ display: inline-flex;
663
+ gap: 4px;
664
+ align-items: center;
665
+ }
666
+ .ys-calendar__legend-today::before {
667
+ display: inline-block;
668
+ width: 10px;
669
+ height: 10px;
670
+ border-radius: 50%;
671
+ background: var(--ys-color-primary);
672
+ content: "";
673
+ }
674
+
675
+ /* 迷你模式:只有日期、休班角标和事件圆点,悬停看完整信息 */
676
+ .ys-calendar.is-small .ys-calendar__weekday {
677
+ padding: 4px 0;
678
+ text-align: center;
679
+ }
680
+ .ys-calendar.is-small .ys-calendar__cell {
681
+ align-items: center;
682
+ justify-content: center;
683
+ min-height: 36px;
684
+ padding: 2px;
685
+ }
686
+ .ys-calendar.is-small .ys-calendar__cell + .ys-calendar__cell {
687
+ border-left: 0;
688
+ }
689
+ .ys-calendar.is-small .ys-calendar__row + .ys-calendar__row {
690
+ border-top: 0;
691
+ }
692
+ /* 角标跟着日期数字:top 只包住数字,角标挂在数字右上角(不超出最右一列) */
693
+ .ys-calendar.is-small .ys-calendar__top {
694
+ position: relative;
695
+ display: inline-flex;
696
+ }
697
+ .ys-calendar.is-small .ys-calendar__date {
698
+ font-size: 12px;
699
+ font-weight: 500;
700
+ }
701
+ .ys-calendar.is-small .ys-calendar__badge {
702
+ position: absolute;
703
+ top: -5px;
704
+ right: -6px;
705
+ width: 12px;
706
+ height: 12px;
707
+ font-size: 9px;
708
+ }
709
+ .ys-calendar__dot {
710
+ width: 4px;
711
+ height: 4px;
712
+ border-radius: 50%;
713
+ background: var(--ys-color-primary);
714
+ }
715
+ </style>
package/src/index.ts CHANGED
@@ -3,13 +3,19 @@
3
3
  export { default as YsCrudTable } from "./components/YsCrudTable.vue";
4
4
  export { default as YsTableToolbar } from "./components/YsTableToolbar.vue";
5
5
  export { default as YsStatusFilter } from "./components/YsStatusFilter.vue";
6
+ export { default as YsCalendar } from "./components/YsCalendar.vue";
7
+ export type { YsCalendarEvent } from "./components/YsCalendar.vue";
6
8
  export { default as YsTablePagination } from "./components/YsTablePagination.vue";
7
9
  export { default as YsRowActionMenu } from "./components/YsRowActionMenu.vue";
8
10
  export type { YsRowAction } from "./components/YsRowActionMenu.vue";
9
11
  export { default as YsFormDialog } from "./components/YsFormDialog.vue";
10
12
  export { default as YsSelect } from "./components/YsSelect.vue";
11
13
  export { default as YsTreeSelect } from "./components/YsTreeSelect.vue";
12
- export { useYsOptionFilter, ysTreeFilter, type YsOptionFilter } from "./optionFilter";
14
+ export {
15
+ useYsOptionFilter,
16
+ ysTreeFilter,
17
+ type YsOptionFilter,
18
+ } from "./optionFilter";
13
19
  export { default as YsDialog } from "./components/YsDialog.vue";
14
20
  export { dialogTitle, ysConfirm, type YsConfirmOptions } from "./dialog";
15
21
  export { default as YsLoadError } from "./components/YsLoadError.vue";