@ysgroup/ui 0.1.64 → 0.2.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/package.json +3 -3
- package/src/components/YsCalendar.vue +372 -223
- package/src/components/YsCalendarDayCard.vue +108 -46
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ysgroup/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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.
|
|
14
|
+
"@ysgroup/core": ">=0.1.36",
|
|
15
15
|
"@ysgroup/theme": ">=0.3.4",
|
|
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.55",
|
|
29
|
-
"@ysgroup/core": "^0.1.
|
|
29
|
+
"@ysgroup/core": "^0.1.36",
|
|
30
30
|
"@ysgroup/theme": "^0.3.4",
|
|
31
31
|
"docx-preview": "^0.4.1"
|
|
32
32
|
}
|
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* 月历:一种综合样式,同时回答「要不要上班」「开不开市」「当晚有没有夜盘」。
|
|
4
4
|
*
|
|
5
|
-
* -
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
5
|
+
* - 底色只看上不上班:工作日和法定补班(调休上班的周末)浅绿,法定放假浅橙,普通周末不上底色。
|
|
6
|
+
* - 右上角先写上班类标签、再写「开市」:工作日「上班」(绿描边),法定补班「补班」(绿实心,最醒目),放假「放假」(橙描边);
|
|
7
|
+
* 交易日后面再加「开市」(蓝色浅底)。周末不写字,日期数字变灰。放不下时「开市」自动退到「上班」下面,不截断。
|
|
8
|
+
* - 标签下面一行:交易所额外休市写「交易所休市」(灰),法定补班写「节日名调休」,放假写节日名。
|
|
9
|
+
* - 右下角是格子里最后一个元素「夜盘」(靛紫实心),表示当天晚上 21:00 起有期货夜盘(计入下一个交易日);
|
|
10
|
+
* 没有夜盘、夜盘未知都不写,原因看 YsCalendarDayCard。showOrdinal 时左下角写本月第几个交易日(默认不写)。
|
|
10
11
|
* - 上月、下月的格子只留淡底色和日期,不写标签。
|
|
11
|
-
* - 标签文字可以用 labels
|
|
12
|
+
* - 标签文字可以用 labels 改;showLabel 关掉右上角标签(底色、夜盘照常)。
|
|
12
13
|
* - 日期信息(days)由服务端 ys_base.calendar 下发,组件只显示,不自己按周一到周五猜;某天 covered 为 false 表示这一年
|
|
13
|
-
*
|
|
14
|
-
* -
|
|
14
|
+
* 还没有放假安排,顶部写明、格子不标状态。没有 days 时就是普通月历,只显示日期和事件。
|
|
15
|
+
* - 图例按条件突出:上班(含补班)、补班、放假、开市、夜盘;悬停临时突出,点一下固定,再点或按 Esc 取消,读屏会播报。
|
|
15
16
|
* - v-model 是选中日期,v-model:month 是显示的月份(`YYYY-MM`);翻月后按 ysMonthRange(month) 取这一屏的日期信息。
|
|
16
17
|
* - 键盘:方向键移动一天或一周,PageUp / PageDown 翻月,Home / End 到本周一 / 周日,Enter 或空格选中;跨月自动翻页。
|
|
17
|
-
* - 事件条(events)每格最多 maxEvents
|
|
18
|
-
*
|
|
19
|
-
* -
|
|
18
|
+
* - 事件条(events)每格最多 maxEvents 条(有日期信息时默认 2 条,没有时 3 条),其余收成「+N」(触发 more);
|
|
19
|
+
* 要完全自定义格子内容用 #day 插槽。
|
|
20
|
+
* - 紧凑格子(size="small" 或手机):只有日期、底色、「班」「休」角标、日期下方蓝色短横(开市)和短横后的靛紫圆点(夜盘),
|
|
21
|
+
* 事件圆点在左上角。
|
|
20
22
|
* - years:各年数据来源与核对状态(服务端 CalendarService.year_states()),传了就在顶部写这一屏所在年份的来源,
|
|
21
23
|
* 如「2026 年:Auth 下发 · 已与交易所核对」,悬停看各数据源的核对结果。
|
|
24
|
+
* - mark、trading、night 是以前分视图时的参数,现在只有一种样式,传了也不起作用。
|
|
22
25
|
*/
|
|
23
26
|
import { computed, nextTick, ref, watch } from "vue";
|
|
24
27
|
import { useYsMobile } from "../viewport";
|
|
25
28
|
import {
|
|
26
29
|
YS_DAY_KIND_LABELS,
|
|
30
|
+
YS_NIGHT_SESSION_START,
|
|
27
31
|
YS_TRADING_TAG_LABELS,
|
|
28
32
|
YS_WEEKDAY_LABELS,
|
|
29
33
|
ysAddDays,
|
|
@@ -33,6 +37,7 @@ import {
|
|
|
33
37
|
ysMonthOf,
|
|
34
38
|
ysMonthSummary,
|
|
35
39
|
ysShiftMonth,
|
|
40
|
+
ysShortDateTitle,
|
|
36
41
|
ysToday,
|
|
37
42
|
ysTradingMarks,
|
|
38
43
|
ysWeekday,
|
|
@@ -50,7 +55,10 @@ export interface YsCalendarEvent {
|
|
|
50
55
|
tone?: "primary" | "success" | "warning" | "danger" | "info";
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* 格子状态:交易日 trading,其余按工作类型 workday(上班但交易所休市)/ adjusted / weekend / holiday。
|
|
60
|
+
* closed 是以前交易日视图的休市,现在不再出现,只为兼容保留在类型里。
|
|
61
|
+
*/
|
|
54
62
|
export type YsCalendarStatus =
|
|
55
63
|
| "trading"
|
|
56
64
|
| "closed"
|
|
@@ -58,16 +66,24 @@ export type YsCalendarStatus =
|
|
|
58
66
|
| "adjusted"
|
|
59
67
|
| "weekend"
|
|
60
68
|
| "holiday";
|
|
61
|
-
/**
|
|
62
|
-
export type YsCalendarLabels = Record<YsCalendarStatus, string>;
|
|
69
|
+
/** 标签上的文字:各状态加夜盘 night。 */
|
|
70
|
+
export type YsCalendarLabels = Record<YsCalendarStatus | "night", string>;
|
|
71
|
+
/** 图例能突出的几类:上班(含补班)、补班、放假、开市、夜盘。 */
|
|
72
|
+
export type YsCalendarLegendKey =
|
|
73
|
+
| "workday"
|
|
74
|
+
| "adjusted"
|
|
75
|
+
| "holiday"
|
|
76
|
+
| "trading"
|
|
77
|
+
| "night";
|
|
63
78
|
|
|
64
79
|
const DEFAULT_LABELS: YsCalendarLabels = {
|
|
65
|
-
trading: "
|
|
80
|
+
trading: "开市",
|
|
66
81
|
closed: "休市",
|
|
67
|
-
workday: "
|
|
68
|
-
adjusted: "
|
|
82
|
+
workday: "上班",
|
|
83
|
+
adjusted: "补班",
|
|
69
84
|
weekend: "休息",
|
|
70
85
|
holiday: "放假",
|
|
86
|
+
night: "夜盘",
|
|
71
87
|
};
|
|
72
88
|
|
|
73
89
|
const props = withDefaults(
|
|
@@ -79,24 +95,25 @@ const props = withDefaults(
|
|
|
79
95
|
today?: string;
|
|
80
96
|
loading?: boolean;
|
|
81
97
|
size?: "default" | "small";
|
|
82
|
-
/**
|
|
98
|
+
/** @deprecated 以前的视图切换,现在只有一种综合样式,传了不起作用。 */
|
|
83
99
|
mark?: "work" | "trading" | "none";
|
|
84
|
-
/**
|
|
100
|
+
/** @deprecated 以前等于 mark="trading",现在不起作用。 */
|
|
85
101
|
trading?: boolean;
|
|
86
|
-
/** 改标签文字,只写要改的几项,如 { adjusted: "
|
|
102
|
+
/** 改标签文字,只写要改的几项,如 { adjusted: "调休" }。 */
|
|
87
103
|
labels?: Partial<YsCalendarLabels>;
|
|
88
|
-
/**
|
|
104
|
+
/** 每格右上角显示上班、开市等标签(底色和夜盘照常)。 */
|
|
89
105
|
showLabel?: boolean;
|
|
90
|
-
/**
|
|
106
|
+
/** 左下角写本月第几个交易日(默认不写,选中日详情里写)。 */
|
|
91
107
|
showOrdinal?: boolean;
|
|
92
|
-
/**
|
|
108
|
+
/** 顶部显示本月统计(开市、上班(含补班)、放假、交易所休市、夜盘)。 */
|
|
93
109
|
summary?: boolean;
|
|
110
|
+
/** 每格最多几条事件;不传时有日期信息 2 条、没有 3 条。 */
|
|
94
111
|
maxEvents?: number;
|
|
95
112
|
/** 不能选的日期(如非交易日):变淡、点了不选中。 */
|
|
96
113
|
disabledDate?: (date: string, info?: YsCalendarDay) => boolean;
|
|
97
114
|
/** 显示底部图例;默认有日期信息时显示。 */
|
|
98
115
|
legend?: boolean | null;
|
|
99
|
-
/**
|
|
116
|
+
/** @deprecated 夜盘现在有数据就标,传了不起作用。 */
|
|
100
117
|
night?: boolean;
|
|
101
118
|
/** 各年数据来源与核对状态;传了就在顶部写这一屏所在年份的来源。 */
|
|
102
119
|
years?: readonly YsCalendarYearInfo[];
|
|
@@ -115,7 +132,7 @@ const props = withDefaults(
|
|
|
115
132
|
showLabel: true,
|
|
116
133
|
showOrdinal: false,
|
|
117
134
|
summary: false,
|
|
118
|
-
maxEvents:
|
|
135
|
+
maxEvents: undefined,
|
|
119
136
|
disabledDate: undefined,
|
|
120
137
|
legend: null,
|
|
121
138
|
night: false,
|
|
@@ -161,22 +178,19 @@ const eventMap = computed(() => {
|
|
|
161
178
|
});
|
|
162
179
|
const small = computed(() => props.size === "small");
|
|
163
180
|
/**
|
|
164
|
-
* 格子紧凑:迷你模式,或者手机(≤767px,每格只有 50px
|
|
165
|
-
* 紧凑时格子里只有日期、底色、休 /
|
|
181
|
+
* 格子紧凑:迷你模式,或者手机(≤767px,每格只有 50px 左右宽,放不下文字标签和事件条)。
|
|
182
|
+
* 紧凑时格子里只有日期、底色、休 / 班角标、开市短横、夜盘圆点和事件圆点;详情看旁边的 YsCalendarDayCard。
|
|
166
183
|
*/
|
|
167
184
|
const mobile = useYsMobile();
|
|
168
185
|
const compact = computed(() => small.value || mobile.value);
|
|
169
|
-
const view = computed(() => props.mark ?? (props.trading ? "trading" : "none"));
|
|
170
|
-
const tradingView = computed(() => view.value === "trading");
|
|
171
186
|
const labelText = computed<YsCalendarLabels>(() => ({
|
|
172
187
|
...DEFAULT_LABELS,
|
|
173
188
|
...props.labels,
|
|
174
189
|
}));
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
? ysTradingMarks(props.days)
|
|
178
|
-
: new Map<string, YsTradingMark>(),
|
|
190
|
+
const eventLimit = computed(
|
|
191
|
+
() => props.maxEvents ?? (props.days.length ? 2 : 3),
|
|
179
192
|
);
|
|
193
|
+
const marks = computed(() => ysTradingMarks(props.days));
|
|
180
194
|
|
|
181
195
|
/** 这一屏里还没有放假安排的年份。 */
|
|
182
196
|
const missingYears = computed(() => {
|
|
@@ -216,25 +230,25 @@ const todayVisible = computed(() =>
|
|
|
216
230
|
cells.value.some((cell) => cell.date === todayText.value),
|
|
217
231
|
);
|
|
218
232
|
|
|
219
|
-
/**
|
|
233
|
+
/** 顶部统计:「开市 21 · 上班 22(含补班 1)· 放假 3 · 交易所休市 1 · 夜盘 17」,为 0 的项省略。月份信息不全时不显示。 */
|
|
220
234
|
const summaryParts = computed(() => {
|
|
221
|
-
if (!props.summary || small.value ||
|
|
235
|
+
if (!props.summary || small.value || !props.days.length) return [];
|
|
222
236
|
const value = ysMonthSummary(props.days, shownMonth.value);
|
|
223
237
|
if (!value.complete) return [];
|
|
224
238
|
const labels = labelText.value;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
{ label: labels.workday, value: value.workdays - value.adjusted },
|
|
239
|
+
const parts: { label: string; value: number; note?: string }[] = [
|
|
240
|
+
{ label: labels.trading, value: value.trading },
|
|
241
|
+
{
|
|
242
|
+
label: labels.workday,
|
|
243
|
+
value: value.workdays,
|
|
244
|
+
note: value.adjusted ? `含${labels.adjusted} ${value.adjusted}` : "",
|
|
245
|
+
},
|
|
233
246
|
];
|
|
234
|
-
if (value.adjusted)
|
|
235
|
-
parts.push({ label: labels.adjusted, value: value.adjusted });
|
|
236
247
|
if (value.holidays)
|
|
237
248
|
parts.push({ label: labels.holiday, value: value.holidays });
|
|
249
|
+
if (value.marketClosed)
|
|
250
|
+
parts.push({ label: "交易所休市", value: value.marketClosed });
|
|
251
|
+
if (value.night) parts.push({ label: labels.night, value: value.night });
|
|
238
252
|
return parts;
|
|
239
253
|
});
|
|
240
254
|
|
|
@@ -251,62 +265,70 @@ function info(date: string): YsCalendarDay | undefined {
|
|
|
251
265
|
function eventsOf(date: string): YsCalendarEvent[] {
|
|
252
266
|
return eventMap.value.get(date) ?? [];
|
|
253
267
|
}
|
|
254
|
-
|
|
268
|
+
/** 有日期信息、这一年有放假安排时才是可信的那天信息。 */
|
|
269
|
+
function known(date: string): YsCalendarDay | undefined {
|
|
255
270
|
const item = info(date);
|
|
256
|
-
return
|
|
271
|
+
return item && item.covered !== false ? item : undefined;
|
|
257
272
|
}
|
|
258
|
-
/**
|
|
273
|
+
/** 这一天的状态:交易日 trading,其余按工作类型;没有日期信息或这一年没有放假安排时为空。 */
|
|
259
274
|
function status(date: string): YsCalendarStatus | "" {
|
|
260
|
-
|
|
261
|
-
const item = info(date);
|
|
275
|
+
const item = known(date);
|
|
262
276
|
if (!item) return "";
|
|
263
|
-
|
|
264
|
-
return item.kind;
|
|
277
|
+
return item.trading ? "trading" : item.kind;
|
|
265
278
|
}
|
|
266
|
-
/**
|
|
279
|
+
/** 上月、下月的格子只留淡底色和日期,标签、序号、节日名、夜盘只在本月写。 */
|
|
267
280
|
function inShownMonth(date: string): boolean {
|
|
268
281
|
return date.startsWith(shownMonth.value);
|
|
269
282
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
283
|
+
/** 右上角标签:先上班类(上班 / 补班 / 放假,周末不写),再开市。 */
|
|
284
|
+
function cellLabels(
|
|
285
|
+
date: string,
|
|
286
|
+
): { key: YsCalendarLegendKey; text: string }[] {
|
|
287
|
+
const item = known(date);
|
|
288
|
+
if (!item || !inShownMonth(date)) return [];
|
|
289
|
+
const labels = labelText.value;
|
|
290
|
+
const list: { key: YsCalendarLegendKey; text: string }[] = [];
|
|
291
|
+
if (item.kind === "adjusted")
|
|
292
|
+
list.push({ key: "adjusted", text: labels.adjusted });
|
|
293
|
+
else if (item.kind === "holiday")
|
|
294
|
+
list.push({ key: "holiday", text: labels.holiday });
|
|
295
|
+
else if (item.kind === "workday")
|
|
296
|
+
list.push({ key: "workday", text: labels.workday });
|
|
297
|
+
if (item.trading) list.push({ key: "trading", text: labels.trading });
|
|
298
|
+
return list;
|
|
299
|
+
}
|
|
300
|
+
/** 迷你模式和手机在数字右上角挂「休」「班」小角标。 */
|
|
276
301
|
function badge(date: string): "休" | "班" | "" {
|
|
277
302
|
if (!inShownMonth(date)) return "";
|
|
278
|
-
const
|
|
279
|
-
return
|
|
303
|
+
const kind = known(date)?.kind;
|
|
304
|
+
return kind === "holiday" ? "休" : kind === "adjusted" ? "班" : "";
|
|
280
305
|
}
|
|
281
306
|
function isWeekendCell(cell: YsMonthCell): boolean {
|
|
282
|
-
const
|
|
283
|
-
if (
|
|
307
|
+
const item = known(cell.date);
|
|
308
|
+
if (item) return item.kind === "weekend" || item.kind === "holiday";
|
|
284
309
|
return cell.weekday >= 5;
|
|
285
310
|
}
|
|
286
|
-
/**
|
|
287
|
-
* 交易所额外休市写「交易所休市」,夜盘视图下没有夜盘的交易日写「无夜盘」。 */
|
|
311
|
+
/** 标签下面那一行:交易所额外休市写「交易所休市」,法定补班写「国庆节调休」,放假写节日名。 */
|
|
288
312
|
function subline(date: string): string {
|
|
289
313
|
if (!inShownMonth(date)) return "";
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
314
|
+
const item = known(date);
|
|
315
|
+
if (!item) return "";
|
|
316
|
+
if (item.market_closed) return "交易所休市";
|
|
317
|
+
if (!item.name) return "";
|
|
318
|
+
if (item.kind === "adjusted") return `${item.name}调休`;
|
|
319
|
+
if (item.kind === "holiday") return item.name;
|
|
320
|
+
return "";
|
|
321
|
+
}
|
|
322
|
+
/** 当晚有期货夜盘的交易日(没有、未知都不标)。 */
|
|
323
|
+
function nightOn(date: string): boolean {
|
|
324
|
+
const item = known(date);
|
|
325
|
+
return Boolean(item?.trading && item.night_session === true);
|
|
326
|
+
}
|
|
302
327
|
function hasNight(date: string): boolean {
|
|
303
|
-
return (
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
status(date) === "trading" &&
|
|
308
|
-
info(date)?.night_session === true
|
|
309
|
-
);
|
|
328
|
+
return inShownMonth(date) && nightOn(date);
|
|
329
|
+
}
|
|
330
|
+
function isOpen(date: string): boolean {
|
|
331
|
+
return inShownMonth(date) && Boolean(known(date)?.trading);
|
|
310
332
|
}
|
|
311
333
|
function ordinalOf(date: string): number | undefined {
|
|
312
334
|
return props.showOrdinal && inShownMonth(date)
|
|
@@ -319,35 +341,45 @@ function markOf(date: string): YsTradingMark | undefined {
|
|
|
319
341
|
function disabled(date: string): boolean {
|
|
320
342
|
return Boolean(props.disabledDate?.(date, info(date)));
|
|
321
343
|
}
|
|
344
|
+
/** 读屏念的整句话:日期,上班类,开市或休市,当晚夜盘,关键交易日,今天,事项。 */
|
|
322
345
|
function ariaLabel(cell: YsMonthCell): string {
|
|
323
346
|
const item = info(cell.date);
|
|
324
347
|
const parts = [ysDateTitle(cell.date)];
|
|
325
348
|
if (item?.covered === false) parts.push("放假安排还没有");
|
|
326
|
-
else if (item
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
349
|
+
else if (item) {
|
|
350
|
+
const name = item.name ?? "";
|
|
351
|
+
if (item.kind === "workday") parts.push("上班");
|
|
352
|
+
else if (item.kind === "adjusted")
|
|
353
|
+
parts.push(
|
|
354
|
+
name
|
|
355
|
+
? `${YS_DAY_KIND_LABELS.adjusted}(${name}调休)`
|
|
356
|
+
: YS_DAY_KIND_LABELS.adjusted,
|
|
357
|
+
);
|
|
358
|
+
else if (item.kind === "holiday")
|
|
359
|
+
parts.push(name ? `放假 ${name}` : "放假");
|
|
360
|
+
else parts.push(YS_DAY_KIND_LABELS.weekend);
|
|
361
|
+
const mark = markOf(cell.date);
|
|
362
|
+
if (item.trading)
|
|
335
363
|
parts.push(
|
|
336
|
-
|
|
337
|
-
? mark?.ordinal
|
|
338
|
-
? `本月第 ${mark.ordinal} 个交易日`
|
|
339
|
-
: "交易日"
|
|
340
|
-
: "休市",
|
|
364
|
+
mark?.ordinal ? `开市,本月第 ${mark.ordinal} 个交易日` : "开市",
|
|
341
365
|
);
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
366
|
+
else if (item.market_closed)
|
|
367
|
+
parts.push(`交易所休市(${item.market_closed})`);
|
|
368
|
+
else parts.push("休市");
|
|
369
|
+
if (item.trading && item.night_session === true)
|
|
370
|
+
parts.push(
|
|
371
|
+
item.night_trading_day
|
|
372
|
+
? `当晚有夜盘,计入 ${ysShortDateTitle(item.night_trading_day)} 交易日`
|
|
373
|
+
: "当晚有夜盘",
|
|
374
|
+
);
|
|
375
|
+
else if (
|
|
376
|
+
item.trading &&
|
|
377
|
+
item.night_session === false &&
|
|
378
|
+
cell.date >= YS_NIGHT_SESSION_START
|
|
379
|
+
)
|
|
380
|
+
parts.push("当晚没有夜盘");
|
|
381
|
+
for (const tag of mark?.tags ?? [])
|
|
382
|
+
parts.push(YS_TRADING_TAG_LABELS[tag].full);
|
|
351
383
|
}
|
|
352
384
|
if (cell.date === todayText.value) parts.push("今天");
|
|
353
385
|
const count = eventsOf(cell.date).length;
|
|
@@ -356,24 +388,44 @@ function ariaLabel(cell: YsMonthCell): string {
|
|
|
356
388
|
return parts.join(",");
|
|
357
389
|
}
|
|
358
390
|
|
|
359
|
-
// ----------
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
391
|
+
// ---------- 图例:按条件突出一类 ----------
|
|
392
|
+
/** 这一天是否属于图例的某一类。 */
|
|
393
|
+
function matches(date: string, key: YsCalendarLegendKey): boolean {
|
|
394
|
+
const item = known(date);
|
|
395
|
+
if (!item) return false;
|
|
396
|
+
if (key === "workday") return Boolean(item.workday);
|
|
397
|
+
if (key === "adjusted") return item.kind === "adjusted";
|
|
398
|
+
if (key === "holiday") return item.kind === "holiday";
|
|
399
|
+
if (key === "trading") return Boolean(item.trading);
|
|
400
|
+
return nightOn(date);
|
|
401
|
+
}
|
|
402
|
+
function legendCount(key: YsCalendarLegendKey): number {
|
|
403
|
+
return cells.value.filter((cell) => cell.inMonth && matches(cell.date, key))
|
|
404
|
+
.length;
|
|
405
|
+
}
|
|
406
|
+
const LEGEND_NOTES: Record<YsCalendarLegendKey, string> = {
|
|
407
|
+
workday: "要上班的日子,含补班",
|
|
408
|
+
adjusted: "调休上班的周末,交易所休市",
|
|
409
|
+
holiday: "法定节假日",
|
|
410
|
+
trading: "交易所开市",
|
|
411
|
+
night: "当晚 21:00 起有期货夜盘",
|
|
412
|
+
};
|
|
413
|
+
/** 上班、开市一直列出;补班、放假、夜盘本月有才列。 */
|
|
414
|
+
const legendItems = computed(() => {
|
|
415
|
+
if (!props.days.length) return [];
|
|
416
|
+
const keys: YsCalendarLegendKey[] = [
|
|
417
|
+
"workday",
|
|
418
|
+
"adjusted",
|
|
419
|
+
"holiday",
|
|
420
|
+
"trading",
|
|
421
|
+
"night",
|
|
422
|
+
];
|
|
423
|
+
return keys
|
|
424
|
+
.map((key) => ({ key, count: legendCount(key) }))
|
|
425
|
+
.filter(
|
|
426
|
+
(item) =>
|
|
427
|
+
item.key === "workday" || item.key === "trading" || item.count > 0,
|
|
428
|
+
);
|
|
377
429
|
});
|
|
378
430
|
const showLegend = computed(
|
|
379
431
|
() =>
|
|
@@ -381,19 +433,38 @@ const showLegend = computed(
|
|
|
381
433
|
(props.legend ?? props.days.length > 0) &&
|
|
382
434
|
(legendItems.value.length > 0 || todayVisible.value),
|
|
383
435
|
);
|
|
384
|
-
const legendHover = ref<
|
|
385
|
-
const legendPinned = ref<
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
});
|
|
391
|
-
function togglePinned(key: YsCalendarStatus) {
|
|
436
|
+
const legendHover = ref<YsCalendarLegendKey | "">("");
|
|
437
|
+
const legendPinned = ref<YsCalendarLegendKey | "">("");
|
|
438
|
+
const focusKey = computed(() => legendHover.value || legendPinned.value);
|
|
439
|
+
/** 固定、取消时给读屏的播报。 */
|
|
440
|
+
const legendAnnounce = ref("");
|
|
441
|
+
function togglePinned(key: YsCalendarLegendKey) {
|
|
392
442
|
legendPinned.value = legendPinned.value === key ? "" : key;
|
|
443
|
+
legendAnnounce.value = legendPinned.value
|
|
444
|
+
? `已只突出${labelText.value[key]},本月 ${legendCount(key)} 天`
|
|
445
|
+
: "已取消突出";
|
|
393
446
|
}
|
|
394
|
-
function
|
|
395
|
-
|
|
396
|
-
|
|
447
|
+
function clearLegend(announce = true) {
|
|
448
|
+
if (!legendPinned.value && !legendHover.value) return;
|
|
449
|
+
legendHover.value = "";
|
|
450
|
+
if (legendPinned.value) {
|
|
451
|
+
legendPinned.value = "";
|
|
452
|
+
if (announce) legendAnnounce.value = "已取消突出";
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
/** 翻月或图例列表变化时,固定的那一项若已不在列表里,自动清掉,避免整屏变淡。 */
|
|
456
|
+
watch(legendItems, (items) => {
|
|
457
|
+
if (legendPinned.value && !items.some((i) => i.key === legendPinned.value)) {
|
|
458
|
+
legendHover.value = "";
|
|
459
|
+
legendPinned.value = "";
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
/** 图例隐藏时(迷你模式、legend=false)同样清掉固定状态。 */
|
|
463
|
+
watch(showLegend, (visible) => {
|
|
464
|
+
if (!visible) clearLegend(false);
|
|
465
|
+
});
|
|
466
|
+
function dimmed(date: string): boolean {
|
|
467
|
+
return Boolean(focusKey.value) && !matches(date, focusKey.value as YsCalendarLegendKey);
|
|
397
468
|
}
|
|
398
469
|
|
|
399
470
|
// ---------- 选择与键盘 ----------
|
|
@@ -443,6 +514,10 @@ function onKeydown(event: KeyboardEvent) {
|
|
|
443
514
|
PageUp: () => shiftKeepDay(current, -1),
|
|
444
515
|
PageDown: () => shiftKeepDay(current, 1),
|
|
445
516
|
};
|
|
517
|
+
if (event.key === "Escape") {
|
|
518
|
+
clearLegend();
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
446
521
|
if (event.key === "Enter" || event.key === " ") {
|
|
447
522
|
event.preventDefault();
|
|
448
523
|
select(current);
|
|
@@ -476,8 +551,7 @@ function goToday() {
|
|
|
476
551
|
'is-small': small,
|
|
477
552
|
'is-compact': compact,
|
|
478
553
|
'is-mobile': mobile,
|
|
479
|
-
'is-
|
|
480
|
-
'is-focusing': Boolean(focusStatus),
|
|
554
|
+
'is-focusing': Boolean(focusKey),
|
|
481
555
|
}"
|
|
482
556
|
>
|
|
483
557
|
<header class="ys-calendar__head">
|
|
@@ -524,7 +598,10 @@ function goToday() {
|
|
|
524
598
|
:key="part.label"
|
|
525
599
|
class="ys-calendar__summary-item"
|
|
526
600
|
><span>{{ part.label }}</span
|
|
527
|
-
><strong>{{ part.value }}</strong
|
|
601
|
+
><strong>{{ part.value }}</strong
|
|
602
|
+
><span v-if="part.note" class="ys-calendar__summary-note"
|
|
603
|
+
>({{ part.note }})</span
|
|
604
|
+
></span
|
|
528
605
|
>
|
|
529
606
|
</div>
|
|
530
607
|
<span
|
|
@@ -584,7 +661,6 @@ function goToday() {
|
|
|
584
661
|
:aria-selected="cell.date === modelValue"
|
|
585
662
|
:aria-disabled="disabled(cell.date) || undefined"
|
|
586
663
|
:aria-label="ariaLabel(cell)"
|
|
587
|
-
:title="ariaLabel(cell)"
|
|
588
664
|
:class="[
|
|
589
665
|
status(cell.date) ? `is-${status(cell.date)}` : '',
|
|
590
666
|
{
|
|
@@ -594,8 +670,7 @@ function goToday() {
|
|
|
594
670
|
'is-weekend-day': isWeekendCell(cell),
|
|
595
671
|
'is-uncovered': info(cell.date)?.covered === false,
|
|
596
672
|
'is-disabled': disabled(cell.date),
|
|
597
|
-
'is-dimmed':
|
|
598
|
-
Boolean(focusStatus) && status(cell.date) !== focusStatus,
|
|
673
|
+
'is-dimmed': dimmed(cell.date),
|
|
599
674
|
},
|
|
600
675
|
]"
|
|
601
676
|
@click="select(cell.date)"
|
|
@@ -617,44 +692,35 @@ function goToday() {
|
|
|
617
692
|
v-if="compact && badge(cell.date)"
|
|
618
693
|
class="ys-calendar__badge"
|
|
619
694
|
:class="badge(cell.date) === '休' ? 'is-off' : 'is-work'"
|
|
695
|
+
aria-hidden="true"
|
|
620
696
|
>{{ badge(cell.date) }}</span
|
|
621
697
|
>
|
|
622
698
|
<span
|
|
623
|
-
v-else-if="
|
|
624
|
-
!compact &&
|
|
625
|
-
(ordinalOf(cell.date) ||
|
|
626
|
-
hasNight(cell.date) ||
|
|
627
|
-
(showLabel && statusLabel(cell.date)))
|
|
628
|
-
"
|
|
699
|
+
v-else-if="!compact && showLabel && cellLabels(cell.date).length"
|
|
629
700
|
class="ys-calendar__status"
|
|
701
|
+
aria-hidden="true"
|
|
630
702
|
>
|
|
631
703
|
<span
|
|
632
|
-
v-
|
|
633
|
-
|
|
634
|
-
aria-hidden="true"
|
|
635
|
-
>第 {{ ordinalOf(cell.date) }} 个</span
|
|
636
|
-
>
|
|
637
|
-
<span
|
|
638
|
-
v-if="hasNight(cell.date)"
|
|
639
|
-
class="ys-calendar__night"
|
|
640
|
-
aria-hidden="true"
|
|
641
|
-
>夜</span
|
|
642
|
-
>
|
|
643
|
-
<span
|
|
644
|
-
v-if="showLabel && statusLabel(cell.date)"
|
|
704
|
+
v-for="label in cellLabels(cell.date)"
|
|
705
|
+
:key="label.key"
|
|
645
706
|
class="ys-calendar__label"
|
|
646
|
-
|
|
647
|
-
>{{
|
|
707
|
+
:class="`is-${label.key}`"
|
|
708
|
+
>{{ label.text }}</span
|
|
648
709
|
>
|
|
649
710
|
</span>
|
|
650
711
|
</div>
|
|
651
712
|
<template v-if="!compact">
|
|
652
|
-
<div
|
|
713
|
+
<div
|
|
714
|
+
v-if="subline(cell.date)"
|
|
715
|
+
class="ys-calendar__name"
|
|
716
|
+
:class="{ 'is-market-closed': info(cell.date)?.market_closed }"
|
|
717
|
+
aria-hidden="true"
|
|
718
|
+
>
|
|
653
719
|
{{ subline(cell.date) }}
|
|
654
720
|
</div>
|
|
655
721
|
<ul v-if="eventsOf(cell.date).length" class="ys-calendar__events">
|
|
656
722
|
<li
|
|
657
|
-
v-for="item in eventsOf(cell.date).slice(0,
|
|
723
|
+
v-for="item in eventsOf(cell.date).slice(0, eventLimit)"
|
|
658
724
|
:key="item.id ?? item.title"
|
|
659
725
|
class="ys-calendar__event"
|
|
660
726
|
:class="`is-${item.tone ?? 'primary'}`"
|
|
@@ -662,22 +728,44 @@ function goToday() {
|
|
|
662
728
|
>
|
|
663
729
|
{{ item.title }}
|
|
664
730
|
</li>
|
|
665
|
-
<li v-if="eventsOf(cell.date).length >
|
|
731
|
+
<li v-if="eventsOf(cell.date).length > eventLimit">
|
|
666
732
|
<button
|
|
667
733
|
type="button"
|
|
668
734
|
class="ys-calendar__more"
|
|
669
735
|
tabindex="-1"
|
|
670
736
|
@click.stop="emit('more', cell.date)"
|
|
671
|
-
v-text="`+${eventsOf(cell.date).length -
|
|
737
|
+
v-text="`+${eventsOf(cell.date).length - eventLimit}`"
|
|
672
738
|
/>
|
|
673
739
|
</li>
|
|
674
740
|
</ul>
|
|
741
|
+
<div
|
|
742
|
+
v-if="ordinalOf(cell.date) || hasNight(cell.date)"
|
|
743
|
+
class="ys-calendar__foot"
|
|
744
|
+
aria-hidden="true"
|
|
745
|
+
>
|
|
746
|
+
<span v-if="ordinalOf(cell.date)" class="ys-calendar__ordinal"
|
|
747
|
+
>第 {{ ordinalOf(cell.date) }} 个</span
|
|
748
|
+
>
|
|
749
|
+
<span v-if="hasNight(cell.date)" class="ys-calendar__night">{{
|
|
750
|
+
labelText.night
|
|
751
|
+
}}</span>
|
|
752
|
+
</div>
|
|
753
|
+
</template>
|
|
754
|
+
<template v-else>
|
|
755
|
+
<span
|
|
756
|
+
v-if="isOpen(cell.date)"
|
|
757
|
+
class="ys-calendar__marks"
|
|
758
|
+
aria-hidden="true"
|
|
759
|
+
><i class="ys-calendar__open-bar" /><i
|
|
760
|
+
v-if="hasNight(cell.date)"
|
|
761
|
+
class="ys-calendar__night-dot"
|
|
762
|
+
/></span>
|
|
763
|
+
<span
|
|
764
|
+
v-if="eventsOf(cell.date).length"
|
|
765
|
+
class="ys-calendar__dot"
|
|
766
|
+
aria-hidden="true"
|
|
767
|
+
/>
|
|
675
768
|
</template>
|
|
676
|
-
<span
|
|
677
|
-
v-else-if="eventsOf(cell.date).length"
|
|
678
|
-
class="ys-calendar__dot"
|
|
679
|
-
aria-hidden="true"
|
|
680
|
-
/>
|
|
681
769
|
</slot>
|
|
682
770
|
</div>
|
|
683
771
|
</div>
|
|
@@ -691,33 +779,36 @@ function goToday() {
|
|
|
691
779
|
class="ys-calendar__legend-item"
|
|
692
780
|
:class="[`is-${item.key}`, { 'is-active': legendPinned === item.key }]"
|
|
693
781
|
:aria-pressed="legendPinned === item.key"
|
|
694
|
-
:title="
|
|
782
|
+
:title="`${LEGEND_NOTES[item.key]};点一下只突出这一类,再点或按 Esc 取消`"
|
|
695
783
|
@mouseenter="legendHover = item.key"
|
|
696
784
|
@mouseleave="legendHover = ''"
|
|
697
785
|
@focus="legendHover = item.key"
|
|
698
786
|
@blur="legendHover = ''"
|
|
787
|
+
@keydown.esc="() => clearLegend()"
|
|
699
788
|
@click="togglePinned(item.key)"
|
|
700
789
|
>
|
|
701
|
-
<i
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
item.
|
|
705
|
-
|
|
790
|
+
<i
|
|
791
|
+
class="ys-calendar__swatch"
|
|
792
|
+
:class="{ 'ys-calendar__night': item.key === 'night' }"
|
|
793
|
+
>{{ labelText[item.key] }}</i
|
|
794
|
+
>
|
|
795
|
+
<strong>{{ item.count }}</strong>
|
|
706
796
|
</button>
|
|
707
|
-
<span v-if="night && tradingView" class="ys-calendar__legend-night"
|
|
708
|
-
><i class="ys-calendar__night">夜</i>当晚有期货夜盘</span
|
|
709
|
-
>
|
|
710
797
|
<span v-if="todayVisible" class="ys-calendar__legend-today">今天</span>
|
|
798
|
+
<span class="ys-calendar__sr-only" aria-live="polite">{{
|
|
799
|
+
legendAnnounce
|
|
800
|
+
}}</span>
|
|
711
801
|
</footer>
|
|
712
802
|
</div>
|
|
713
803
|
</template>
|
|
714
804
|
|
|
715
805
|
<style scoped>
|
|
716
806
|
.ys-calendar {
|
|
717
|
-
/*
|
|
718
|
-
--cal-trading: var(--ys-color-
|
|
807
|
+
/* 色调各管一件事:上班(含补班)绿,放假橙,开市主色蓝,夜盘靛紫,休息、休市灰 */
|
|
808
|
+
--cal-trading: var(--ys-color-primary);
|
|
719
809
|
--cal-workday: var(--ys-color-success);
|
|
720
810
|
--cal-holiday: var(--ys-color-warning);
|
|
811
|
+
--cal-night: #5b4bd6;
|
|
721
812
|
--cal-rest: var(--ys-color-text-3);
|
|
722
813
|
/* 底色:不支持相对颜色的浏览器用混色兜底 */
|
|
723
814
|
--cal-open-bg: color-mix(
|
|
@@ -745,6 +836,9 @@ function goToday() {
|
|
|
745
836
|
gap: 8px;
|
|
746
837
|
min-width: 0;
|
|
747
838
|
}
|
|
839
|
+
html[data-theme="dark"] .ys-calendar {
|
|
840
|
+
--cal-night: #a597ff;
|
|
841
|
+
}
|
|
748
842
|
/* 支持相对颜色时,底色固定亮度和饱和度:和休息日(白底/深底)一眼分得开的绿和橙,饱和度仍克制、不刺眼 */
|
|
749
843
|
@supports (color: oklch(from red l c h)) {
|
|
750
844
|
.ys-calendar {
|
|
@@ -822,27 +916,22 @@ function goToday() {
|
|
|
822
916
|
);
|
|
823
917
|
background: color-mix(in srgb, var(--ys-color-warning) 12%, transparent);
|
|
824
918
|
}
|
|
825
|
-
/*
|
|
919
|
+
/* 夜盘:靛紫实心小标签,像夜色;在格子右下角,是格子里最后一个元素 */
|
|
826
920
|
.ys-calendar__night {
|
|
827
921
|
flex: none;
|
|
828
|
-
padding: 0
|
|
829
|
-
border: 1px solid
|
|
922
|
+
padding: 0 4px;
|
|
923
|
+
border: 1px solid var(--cal-night);
|
|
830
924
|
border-radius: var(--ys-radius-s);
|
|
831
|
-
color: color-
|
|
832
|
-
|
|
833
|
-
var(--ys-color-primary) 85%,
|
|
834
|
-
var(--ys-color-text-1)
|
|
835
|
-
);
|
|
925
|
+
color: var(--ys-color-on-solid);
|
|
926
|
+
background: var(--cal-night);
|
|
836
927
|
font-size: 10px;
|
|
837
928
|
font-style: normal;
|
|
838
929
|
font-weight: 600;
|
|
839
930
|
line-height: 14px;
|
|
931
|
+
white-space: nowrap;
|
|
840
932
|
}
|
|
841
|
-
.ys-
|
|
842
|
-
|
|
843
|
-
gap: 5px;
|
|
844
|
-
align-items: center;
|
|
845
|
-
margin-left: 6px;
|
|
933
|
+
.ys-calendar__summary-note {
|
|
934
|
+
color: var(--ys-color-text-3);
|
|
846
935
|
}
|
|
847
936
|
.ys-calendar__extra {
|
|
848
937
|
display: flex;
|
|
@@ -978,7 +1067,7 @@ function goToday() {
|
|
|
978
1067
|
.ys-calendar__top {
|
|
979
1068
|
display: flex;
|
|
980
1069
|
gap: 4px;
|
|
981
|
-
align-items:
|
|
1070
|
+
align-items: flex-start;
|
|
982
1071
|
justify-content: space-between;
|
|
983
1072
|
min-width: 0;
|
|
984
1073
|
}
|
|
@@ -1009,12 +1098,15 @@ function goToday() {
|
|
|
1009
1098
|
color: var(--ys-color-on-solid);
|
|
1010
1099
|
background: var(--ys-color-primary);
|
|
1011
1100
|
}
|
|
1101
|
+
/* 右上角标签组:上班类在前、开市在后;一行放不下时开市退到下一行,仍靠右,不截断 */
|
|
1012
1102
|
.ys-calendar__status {
|
|
1013
|
-
display:
|
|
1014
|
-
|
|
1015
|
-
|
|
1103
|
+
display: flex;
|
|
1104
|
+
flex: 1 1 auto;
|
|
1105
|
+
flex-wrap: wrap;
|
|
1106
|
+
gap: 3px;
|
|
1107
|
+
justify-content: flex-end;
|
|
1016
1108
|
min-width: 0;
|
|
1017
|
-
|
|
1109
|
+
margin-top: 3px;
|
|
1018
1110
|
}
|
|
1019
1111
|
.ys-calendar__ordinal {
|
|
1020
1112
|
overflow: hidden;
|
|
@@ -1023,11 +1115,11 @@ function goToday() {
|
|
|
1023
1115
|
font-variant-numeric: tabular-nums;
|
|
1024
1116
|
white-space: nowrap;
|
|
1025
1117
|
}
|
|
1026
|
-
/*
|
|
1118
|
+
/* 标签:白底同色调描边深字,在有底色的格子上也清楚;补班实心最醒目,开市蓝色浅底,和上班的描边一眼分开 */
|
|
1027
1119
|
.ys-calendar__label,
|
|
1028
1120
|
.ys-calendar__swatch {
|
|
1029
1121
|
flex: none;
|
|
1030
|
-
padding: 0
|
|
1122
|
+
padding: 0 4px;
|
|
1031
1123
|
border: 1px solid color-mix(in srgb, var(--tone) 60%, transparent);
|
|
1032
1124
|
border-radius: var(--ys-radius-s);
|
|
1033
1125
|
color: color-mix(in srgb, var(--tone) 88%, var(--ys-color-text-1));
|
|
@@ -1038,31 +1130,31 @@ function goToday() {
|
|
|
1038
1130
|
line-height: 16px;
|
|
1039
1131
|
white-space: nowrap;
|
|
1040
1132
|
}
|
|
1041
|
-
.ys-
|
|
1042
|
-
.ys-
|
|
1043
|
-
|
|
1044
|
-
.ys-calendar__legend-item.is-weekend .ys-calendar__swatch {
|
|
1045
|
-
border-color: transparent;
|
|
1046
|
-
color: var(--ys-color-text-2);
|
|
1047
|
-
background: color-mix(in srgb, var(--cal-rest) 14%, transparent);
|
|
1133
|
+
.ys-calendar__label.is-workday,
|
|
1134
|
+
.ys-calendar__legend-item.is-workday .ys-calendar__swatch {
|
|
1135
|
+
--tone: var(--cal-workday);
|
|
1048
1136
|
}
|
|
1049
|
-
|
|
1050
|
-
.ys-
|
|
1051
|
-
|
|
1052
|
-
color: color-mix(
|
|
1053
|
-
in srgb,
|
|
1054
|
-
var(--ys-color-primary) 85%,
|
|
1055
|
-
var(--ys-color-text-1)
|
|
1056
|
-
);
|
|
1057
|
-
border-color: color-mix(in srgb, var(--ys-color-primary) 60%, transparent);
|
|
1058
|
-
background: var(--ys-color-bg-elevated);
|
|
1137
|
+
.ys-calendar__label.is-holiday,
|
|
1138
|
+
.ys-calendar__legend-item.is-holiday .ys-calendar__swatch {
|
|
1139
|
+
--tone: var(--cal-holiday);
|
|
1059
1140
|
}
|
|
1060
|
-
.ys-
|
|
1141
|
+
.ys-calendar__label.is-adjusted,
|
|
1061
1142
|
.ys-calendar__legend-item.is-adjusted .ys-calendar__swatch {
|
|
1062
1143
|
border-color: var(--cal-workday);
|
|
1063
1144
|
color: var(--ys-color-on-solid);
|
|
1064
1145
|
background: var(--cal-workday);
|
|
1065
1146
|
}
|
|
1147
|
+
.ys-calendar__legend-item.is-night .ys-calendar__swatch {
|
|
1148
|
+
border-color: var(--cal-night);
|
|
1149
|
+
color: var(--ys-color-on-solid);
|
|
1150
|
+
background: var(--cal-night);
|
|
1151
|
+
}
|
|
1152
|
+
.ys-calendar__label.is-trading,
|
|
1153
|
+
.ys-calendar__legend-item.is-trading .ys-calendar__swatch {
|
|
1154
|
+
border-color: color-mix(in srgb, var(--cal-trading) 55%, transparent);
|
|
1155
|
+
color: color-mix(in srgb, var(--cal-trading) 88%, var(--ys-color-text-1));
|
|
1156
|
+
background: var(--ys-color-primary-soft);
|
|
1157
|
+
}
|
|
1066
1158
|
.ys-calendar__name {
|
|
1067
1159
|
overflow: hidden;
|
|
1068
1160
|
color: color-mix(in srgb, var(--tone) 75%, var(--ys-color-text-1));
|
|
@@ -1072,9 +1164,22 @@ function goToday() {
|
|
|
1072
1164
|
text-overflow: ellipsis;
|
|
1073
1165
|
}
|
|
1074
1166
|
.ys-calendar__cell.is-closed .ys-calendar__name,
|
|
1075
|
-
.ys-calendar__cell.is-weekend .ys-calendar__name
|
|
1167
|
+
.ys-calendar__cell.is-weekend .ys-calendar__name,
|
|
1168
|
+
.ys-calendar__name.is-market-closed {
|
|
1076
1169
|
color: var(--ys-color-text-3);
|
|
1077
1170
|
}
|
|
1171
|
+
/* 底行:左边序号(showOrdinal),右边夜盘;贴着格子底部 */
|
|
1172
|
+
.ys-calendar__foot {
|
|
1173
|
+
display: flex;
|
|
1174
|
+
gap: 4px;
|
|
1175
|
+
align-items: center;
|
|
1176
|
+
justify-content: flex-end;
|
|
1177
|
+
min-width: 0;
|
|
1178
|
+
margin-top: auto;
|
|
1179
|
+
}
|
|
1180
|
+
.ys-calendar__foot .ys-calendar__ordinal {
|
|
1181
|
+
margin-right: auto;
|
|
1182
|
+
}
|
|
1078
1183
|
.ys-calendar__badge {
|
|
1079
1184
|
display: inline-flex;
|
|
1080
1185
|
align-items: center;
|
|
@@ -1181,6 +1286,9 @@ function goToday() {
|
|
|
1181
1286
|
.ys-calendar__legend-item.is-trading {
|
|
1182
1287
|
--tone: var(--cal-trading);
|
|
1183
1288
|
}
|
|
1289
|
+
.ys-calendar__legend-item.is-night {
|
|
1290
|
+
--tone: var(--cal-night);
|
|
1291
|
+
}
|
|
1184
1292
|
.ys-calendar__legend-item.is-workday,
|
|
1185
1293
|
.ys-calendar__legend-item.is-adjusted {
|
|
1186
1294
|
--tone: var(--cal-workday);
|
|
@@ -1243,6 +1351,47 @@ function goToday() {
|
|
|
1243
1351
|
border-radius: 50%;
|
|
1244
1352
|
background: var(--ys-color-primary);
|
|
1245
1353
|
}
|
|
1354
|
+
/* 紧凑格子:日期下方蓝色短横 = 开市,短横后的靛紫圆点 = 当晚有夜盘;事件圆点挪到左上角 */
|
|
1355
|
+
.ys-calendar__marks {
|
|
1356
|
+
display: inline-flex;
|
|
1357
|
+
gap: 2px;
|
|
1358
|
+
align-items: center;
|
|
1359
|
+
height: 4px;
|
|
1360
|
+
margin-top: 2px;
|
|
1361
|
+
}
|
|
1362
|
+
.ys-calendar__open-bar {
|
|
1363
|
+
width: 12px;
|
|
1364
|
+
height: 2px;
|
|
1365
|
+
border-radius: 1px;
|
|
1366
|
+
background: var(--cal-trading);
|
|
1367
|
+
}
|
|
1368
|
+
.ys-calendar__night-dot {
|
|
1369
|
+
width: 4px;
|
|
1370
|
+
height: 4px;
|
|
1371
|
+
border-radius: 50%;
|
|
1372
|
+
background: var(--cal-night);
|
|
1373
|
+
}
|
|
1374
|
+
.ys-calendar.is-compact .ys-calendar__dot {
|
|
1375
|
+
position: absolute;
|
|
1376
|
+
top: 3px;
|
|
1377
|
+
left: 3px;
|
|
1378
|
+
}
|
|
1379
|
+
/* 紧凑格子开市短横和夜盘圆点绝对定位在底部,不撑高格子、不让日期行错位 */
|
|
1380
|
+
.ys-calendar.is-compact .ys-calendar__marks {
|
|
1381
|
+
position: absolute;
|
|
1382
|
+
bottom: 3px;
|
|
1383
|
+
left: 50%;
|
|
1384
|
+
transform: translateX(-50%);
|
|
1385
|
+
margin: 0;
|
|
1386
|
+
}
|
|
1387
|
+
.ys-calendar__sr-only {
|
|
1388
|
+
position: absolute;
|
|
1389
|
+
width: 1px;
|
|
1390
|
+
height: 1px;
|
|
1391
|
+
overflow: hidden;
|
|
1392
|
+
clip: rect(0 0 0 0);
|
|
1393
|
+
white-space: nowrap;
|
|
1394
|
+
}
|
|
1246
1395
|
/* 手机:格子高 44px 好点,月份切换和页面自己的开关(#extra)各占一行 */
|
|
1247
1396
|
.ys-calendar.is-mobile .ys-calendar__cell {
|
|
1248
1397
|
min-height: 44px;
|
|
@@ -2,24 +2,28 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 选中日详情卡:放在 YsCalendar 旁边,介绍选中那天的情况。
|
|
4
4
|
*
|
|
5
|
-
* -
|
|
5
|
+
* - 头部:日期方块(颜色跟月历一致:上班、法定补班浅绿,放假浅橙,休息灰)、完整日期、离今天几天、农历、
|
|
6
6
|
* 传统节日和节气。
|
|
7
|
-
* -
|
|
7
|
+
* - 状态:上班 / 法定补班 / 休息 / 放假,开市 / 休市 / 交易所休市,当晚有夜盘 / 当晚无夜盘,以及节前最后、节后首日、
|
|
8
|
+
* 月初、月末这些关键交易日(全称)。用语和 YsCalendar 格子一致。
|
|
8
9
|
* - 本月位置:几月第 N 个工作日、第 N 个交易日(带进度条),放假时写「国庆节假期第 3 天,共 8 天」。
|
|
9
10
|
* - 当天的事项(events),以及默认插槽放页面自己的内容(如上一个、下一个交易日和 T+N 推算)。
|
|
10
11
|
* - 农历、干支生肖、传统节日和节气默认显示,页面不用加开关;确实不需要的系统传 :lunar="false"。农历用 ysLunar 现算,只用于显示。
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
12
|
+
* - 交易所额外休市(国务院安排上班、交易所休市)写「交易所休市」和原因;交易日写当晚有没有期货夜盘:有就写计入哪个交易日,
|
|
13
|
+
* 没有就写原因(节前最后一个交易日、nightNote 传入的夜盘例外原因、2013-07-05 以前还没有夜盘),未知写明还没有安排
|
|
14
|
+
* (night 关掉不写)。月历格子只标「夜盘」,没有夜盘的原因都在这里。
|
|
13
15
|
* - years 传了就在底部写这一天所在年份的数据来源与核对状态。
|
|
14
16
|
* - 数据都由 @ysgroup/core 的 ysDayDetail 从服务端下发的 days 推出,组件只显示。
|
|
15
17
|
*/
|
|
16
18
|
import { computed } from "vue";
|
|
17
19
|
import {
|
|
20
|
+
YS_NIGHT_SESSION_START,
|
|
18
21
|
YS_TRADING_TAG_LABELS,
|
|
19
22
|
ysDateTitle,
|
|
20
23
|
ysDayDetail,
|
|
21
24
|
ysDaysBetween,
|
|
22
25
|
ysIsDate,
|
|
26
|
+
ysShortDateTitle,
|
|
23
27
|
ysToday,
|
|
24
28
|
ysWeekdayLabel,
|
|
25
29
|
ysCalendarYearText,
|
|
@@ -33,12 +37,13 @@ import type {
|
|
|
33
37
|
} from "./YsCalendar.vue";
|
|
34
38
|
|
|
35
39
|
const DEFAULT_LABELS: YsCalendarLabels = {
|
|
36
|
-
trading: "
|
|
40
|
+
trading: "开市",
|
|
37
41
|
closed: "休市",
|
|
38
|
-
workday: "
|
|
42
|
+
workday: "上班",
|
|
39
43
|
adjusted: "法定补班",
|
|
40
44
|
weekend: "休息",
|
|
41
45
|
holiday: "放假",
|
|
46
|
+
night: "夜盘",
|
|
42
47
|
};
|
|
43
48
|
|
|
44
49
|
const props = withDefaults(
|
|
@@ -57,6 +62,8 @@ const props = withDefaults(
|
|
|
57
62
|
lunar?: boolean;
|
|
58
63
|
/** 交易日写当晚有没有期货夜盘(trading 关掉时也不写)。 */
|
|
59
64
|
night?: boolean;
|
|
65
|
+
/** 这一天的夜盘例外原因(如「疫情期间暂停夜盘」);有就写在当晚无夜盘的说明里。 */
|
|
66
|
+
nightNote?: string;
|
|
60
67
|
/** 各年数据来源与核对状态(服务端 CalendarService.year_states())。 */
|
|
61
68
|
years?: readonly YsCalendarYearInfo[];
|
|
62
69
|
}>(),
|
|
@@ -68,6 +75,7 @@ const props = withDefaults(
|
|
|
68
75
|
trading: true,
|
|
69
76
|
lunar: true,
|
|
70
77
|
night: true,
|
|
78
|
+
nightNote: "",
|
|
71
79
|
years: () => [],
|
|
72
80
|
},
|
|
73
81
|
);
|
|
@@ -138,19 +146,23 @@ const chips = computed(() => {
|
|
|
138
146
|
});
|
|
139
147
|
else list.push({ text: labels[kind], tone: kind });
|
|
140
148
|
if (info.value.market_closed)
|
|
141
|
-
list.push({ text: "交易所休市", tone: "
|
|
142
|
-
if (props.trading)
|
|
149
|
+
list.push({ text: "交易所休市", tone: "closed" });
|
|
150
|
+
else if (props.trading)
|
|
143
151
|
list.push(
|
|
144
152
|
info.value.trading
|
|
145
153
|
? { text: labels.trading, tone: "trading" }
|
|
146
154
|
: { text: labels.closed, tone: "closed" },
|
|
147
155
|
);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
156
|
+
if (props.trading) {
|
|
157
|
+
if (props.night && info.value.trading && info.value.night_session === true)
|
|
158
|
+
list.push({ text: `当晚有${labels.night}`, tone: "night", solid: true });
|
|
159
|
+
else if (
|
|
160
|
+
props.night &&
|
|
161
|
+
info.value.trading &&
|
|
162
|
+
info.value.night_session === false &&
|
|
163
|
+
props.date >= YS_NIGHT_SESSION_START
|
|
164
|
+
)
|
|
165
|
+
list.push({ text: `当晚无${labels.night}`, tone: "closed" });
|
|
154
166
|
for (const tag of detail.value.tags)
|
|
155
167
|
list.push({ text: YS_TRADING_TAG_LABELS[tag].full, tone: "key" });
|
|
156
168
|
}
|
|
@@ -165,21 +177,21 @@ const positions = computed(() => {
|
|
|
165
177
|
const month = `${monthNumber.value} 月`;
|
|
166
178
|
if (holiday)
|
|
167
179
|
list.push({
|
|
168
|
-
label: `${holiday.name}
|
|
180
|
+
label: `${holiday.name}假期 第 ${holiday.index} 天`,
|
|
169
181
|
index: holiday.index,
|
|
170
182
|
total: holiday.total,
|
|
171
183
|
tone: "holiday",
|
|
172
184
|
});
|
|
173
185
|
if (workday)
|
|
174
186
|
list.push({
|
|
175
|
-
label: `${month}第 ${workday.index} 个工作日`,
|
|
187
|
+
label: `${month} 第 ${workday.index} 个工作日`,
|
|
176
188
|
index: workday.index,
|
|
177
189
|
total: workday.total,
|
|
178
190
|
tone: "workday",
|
|
179
191
|
});
|
|
180
192
|
if (trading && props.trading)
|
|
181
193
|
list.push({
|
|
182
|
-
label: `${month}第 ${trading.index} 个交易日`,
|
|
194
|
+
label: `${month} 第 ${trading.index} 个交易日`,
|
|
183
195
|
index: trading.index,
|
|
184
196
|
total: trading.total,
|
|
185
197
|
tone: "trading",
|
|
@@ -187,31 +199,41 @@ const positions = computed(() => {
|
|
|
187
199
|
return list;
|
|
188
200
|
});
|
|
189
201
|
|
|
190
|
-
/**
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
202
|
+
/** 补充说明:法定补班不开市、交易所休市原因、没有放假安排、当晚夜盘计入哪天或为什么没有。 */
|
|
203
|
+
const notes = computed(() => {
|
|
204
|
+
const list: string[] = [];
|
|
205
|
+
if (!valid.value) return list;
|
|
206
|
+
if (info.value?.covered === false) {
|
|
207
|
+
list.push(
|
|
208
|
+
`${props.date.slice(0, 4)} 年的放假安排还没有(国务院办公厅一般在上一年 10–11 月发布),暂不判断工作日和交易日。`,
|
|
209
|
+
);
|
|
210
|
+
return list;
|
|
211
|
+
}
|
|
212
|
+
const item = info.value;
|
|
213
|
+
if (!item) return list;
|
|
214
|
+
if (props.trading && item.kind === "adjusted")
|
|
215
|
+
list.push("法定补班的周末要上班,但交易所照常休市,不开市。");
|
|
216
|
+
if (item.market_closed)
|
|
217
|
+
list.push(`国务院安排这天上班,但交易所休市:${item.market_closed}。`);
|
|
218
|
+
if (!props.trading || !props.night || !item.trading) return list;
|
|
219
|
+
if (item.night_session === true)
|
|
220
|
+
list.push(
|
|
221
|
+
item.night_trading_day
|
|
222
|
+
? `当晚 21:00 起有期货夜盘,计入 ${ysShortDateTitle(item.night_trading_day)} 交易日。`
|
|
223
|
+
: "当晚 21:00 起有期货夜盘。",
|
|
224
|
+
);
|
|
225
|
+
else if (item.night_session === null)
|
|
226
|
+
list.push("下一个交易日所在年份还没有安排,暂不判断当晚有没有夜盘。");
|
|
227
|
+
else if (item.night_session === false) {
|
|
228
|
+
if (props.date < YS_NIGHT_SESSION_START)
|
|
229
|
+
list.push("2013 年 7 月 5 日起才有期货夜盘,这一天还没有夜盘。");
|
|
230
|
+
else if (props.nightNote)
|
|
231
|
+
list.push(`当晚没有夜盘:${props.nightNote}。`);
|
|
232
|
+
else if (detail.value.tags.includes("pre-holiday"))
|
|
233
|
+
list.push("节前最后一个交易日,当晚没有夜盘。");
|
|
234
|
+
// 其余情况(这一屏看不到下一个交易日、夜盘例外又没传原因)不猜原因,状态标签里已经写了「当晚无夜盘」
|
|
235
|
+
}
|
|
236
|
+
return list;
|
|
215
237
|
});
|
|
216
238
|
|
|
217
239
|
const yearInfo = computed(() =>
|
|
@@ -271,6 +293,18 @@ const dayEvents = computed(() =>
|
|
|
271
293
|
>{{ chip.text }}</span
|
|
272
294
|
>
|
|
273
295
|
</div>
|
|
296
|
+
<div
|
|
297
|
+
v-if="detail.tags.length && trading"
|
|
298
|
+
class="ys-day-card__tags"
|
|
299
|
+
aria-label="关键交易日"
|
|
300
|
+
>
|
|
301
|
+
<span
|
|
302
|
+
v-for="tag in detail.tags"
|
|
303
|
+
:key="tag"
|
|
304
|
+
class="ys-day-card__tag"
|
|
305
|
+
>{{ YS_TRADING_TAG_LABELS[tag].full }}</span
|
|
306
|
+
>
|
|
307
|
+
</div>
|
|
274
308
|
|
|
275
309
|
<ul v-if="positions.length" class="ys-day-card__positions">
|
|
276
310
|
<li
|
|
@@ -280,8 +314,8 @@ const dayEvents = computed(() =>
|
|
|
280
314
|
>
|
|
281
315
|
<div class="ys-day-card__position-text">
|
|
282
316
|
<span>{{ item.label }}</span>
|
|
283
|
-
<span class="ys-day-card__position-
|
|
284
|
-
|
|
317
|
+
<span class="ys-day-card__position-count"
|
|
318
|
+
>{{ item.index }} / {{ item.total }}
|
|
285
319
|
{{ item.tone === "holiday" ? "天" : "个" }}</span
|
|
286
320
|
>
|
|
287
321
|
</div>
|
|
@@ -298,7 +332,9 @@ const dayEvents = computed(() =>
|
|
|
298
332
|
</li>
|
|
299
333
|
</ul>
|
|
300
334
|
|
|
301
|
-
<p v-
|
|
335
|
+
<p v-for="text in notes" :key="text" class="ys-day-card__note">
|
|
336
|
+
{{ text }}
|
|
337
|
+
</p>
|
|
302
338
|
|
|
303
339
|
<div v-if="dayEvents.length" class="ys-day-card__events">
|
|
304
340
|
<div class="ys-day-card__section-title">
|
|
@@ -466,6 +502,20 @@ const dayEvents = computed(() =>
|
|
|
466
502
|
flex-wrap: wrap;
|
|
467
503
|
gap: 6px;
|
|
468
504
|
}
|
|
505
|
+
.ys-day-card__tags {
|
|
506
|
+
display: flex;
|
|
507
|
+
flex-wrap: wrap;
|
|
508
|
+
gap: 5px;
|
|
509
|
+
}
|
|
510
|
+
.ys-day-card__tag {
|
|
511
|
+
padding: 1px 8px;
|
|
512
|
+
border-radius: var(--ys-radius-s);
|
|
513
|
+
color: color-mix(in srgb, var(--ys-color-warning) 85%, var(--ys-color-text-1));
|
|
514
|
+
background: color-mix(in srgb, var(--ys-color-warning) 10%, transparent);
|
|
515
|
+
font-size: 11px;
|
|
516
|
+
font-weight: 600;
|
|
517
|
+
line-height: 18px;
|
|
518
|
+
}
|
|
469
519
|
.ys-day-card__chip {
|
|
470
520
|
--chip: var(--ys-color-text-3);
|
|
471
521
|
padding: 1px 8px;
|
|
@@ -486,6 +536,14 @@ const dayEvents = computed(() =>
|
|
|
486
536
|
}
|
|
487
537
|
.ys-day-card__chip.is-trading {
|
|
488
538
|
--chip: var(--ys-color-primary);
|
|
539
|
+
background: var(--ys-color-primary-soft);
|
|
540
|
+
}
|
|
541
|
+
/* 夜盘和月历格子同一个靛紫 */
|
|
542
|
+
.ys-day-card__chip.is-night {
|
|
543
|
+
--chip: #5b4bd6;
|
|
544
|
+
}
|
|
545
|
+
html[data-theme="dark"] .ys-day-card__chip.is-night {
|
|
546
|
+
--chip: #a597ff;
|
|
489
547
|
}
|
|
490
548
|
.ys-day-card__chip.is-weekend,
|
|
491
549
|
.ys-day-card__chip.is-closed {
|
|
@@ -526,7 +584,11 @@ const dayEvents = computed(() =>
|
|
|
526
584
|
font-size: 13px;
|
|
527
585
|
font-weight: 500;
|
|
528
586
|
}
|
|
529
|
-
.ys-day-card__position-
|
|
587
|
+
.ys-day-card__position-text > span:first-child {
|
|
588
|
+
letter-spacing: 0.03em;
|
|
589
|
+
font-variant-numeric: tabular-nums;
|
|
590
|
+
}
|
|
591
|
+
.ys-day-card__position-count {
|
|
530
592
|
color: var(--ys-color-text-3);
|
|
531
593
|
font-size: 12px;
|
|
532
594
|
font-weight: 400;
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { default as YsCalendar } from "./components/YsCalendar.vue";
|
|
|
7
7
|
export type {
|
|
8
8
|
YsCalendarEvent,
|
|
9
9
|
YsCalendarLabels,
|
|
10
|
+
YsCalendarLegendKey,
|
|
10
11
|
YsCalendarStatus,
|
|
11
12
|
} from "./components/YsCalendar.vue";
|
|
12
13
|
export { default as YsCalendarDayCard } from "./components/YsCalendarDayCard.vue";
|