@ysgroup/ui 0.1.60 → 0.1.61
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.
|
|
3
|
+
"version": "0.1.61",
|
|
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.34",
|
|
15
15
|
"@ysgroup/theme": ">=0.3.3",
|
|
16
16
|
"element-plus": ">=2.9",
|
|
17
17
|
"vue": ">=3.5"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@ysgroup/contracts": "^0.1.
|
|
29
|
-
"@ysgroup/core": "^0.1.
|
|
28
|
+
"@ysgroup/contracts": "^0.1.53",
|
|
29
|
+
"@ysgroup/core": "^0.1.34",
|
|
30
30
|
"@ysgroup/theme": "^0.3.3",
|
|
31
31
|
"docx-preview": "^0.4.1"
|
|
32
32
|
}
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
* - v-model 是选中日期,v-model:month 是显示的月份(`YYYY-MM`);翻月后按 ysMonthRange(month) 取这一屏的日期信息。
|
|
16
16
|
* - 键盘:方向键移动一天或一周,PageUp / PageDown 翻月,Home / End 到本周一 / 周日,Enter 或空格选中;跨月自动翻页。
|
|
17
17
|
* - 事件条(events)每格最多 maxEvents 条,其余收成「+N」(触发 more);要完全自定义格子内容用 #day 插槽。
|
|
18
|
+
* - 交易所额外休市(国务院安排上班、交易所休市,如 2024-02-09 除夕):交易日视图按休市显示,两种视图都写「交易所休市」。
|
|
19
|
+
* - night:交易日视图标出期货夜盘——当晚有夜盘的交易日在标签旁写小「夜」,节前等没有夜盘的交易日写「无夜盘」。
|
|
20
|
+
* - years:各年数据来源与核对状态(服务端 CalendarService.year_states()),传了就在顶部写这一屏所在年份的来源,
|
|
21
|
+
* 如「2026 年:Auth 下发 · 已与交易所核对」,悬停看各数据源的核对结果。
|
|
18
22
|
*/
|
|
19
23
|
import { computed, nextTick, ref, watch } from "vue";
|
|
20
24
|
import {
|
|
@@ -31,7 +35,9 @@ import {
|
|
|
31
35
|
ysToday,
|
|
32
36
|
ysTradingMarks,
|
|
33
37
|
ysWeekday,
|
|
38
|
+
ysCalendarYearText,
|
|
34
39
|
type YsCalendarDay,
|
|
40
|
+
type YsCalendarYearInfo,
|
|
35
41
|
type YsMonthCell,
|
|
36
42
|
type YsTradingMark,
|
|
37
43
|
} from "@ysgroup/core";
|
|
@@ -89,6 +95,10 @@ const props = withDefaults(
|
|
|
89
95
|
disabledDate?: (date: string, info?: YsCalendarDay) => boolean;
|
|
90
96
|
/** 显示底部图例;默认有日期信息时显示。 */
|
|
91
97
|
legend?: boolean | null;
|
|
98
|
+
/** 交易日视图标出期货夜盘(有夜盘写「夜」,没有写「无夜盘」)。 */
|
|
99
|
+
night?: boolean;
|
|
100
|
+
/** 各年数据来源与核对状态;传了就在顶部写这一屏所在年份的来源。 */
|
|
101
|
+
years?: readonly YsCalendarYearInfo[];
|
|
92
102
|
}>(),
|
|
93
103
|
{
|
|
94
104
|
modelValue: "",
|
|
@@ -107,6 +117,8 @@ const props = withDefaults(
|
|
|
107
117
|
maxEvents: 3,
|
|
108
118
|
disabledDate: undefined,
|
|
109
119
|
legend: null,
|
|
120
|
+
night: false,
|
|
121
|
+
years: () => [],
|
|
110
122
|
},
|
|
111
123
|
);
|
|
112
124
|
|
|
@@ -167,6 +179,32 @@ const missingYears = computed(() => {
|
|
|
167
179
|
years.add(cell.date.slice(0, 4));
|
|
168
180
|
return [...years].sort();
|
|
169
181
|
});
|
|
182
|
+
/** 这一屏所在年份(本月)的数据来源说明。 */
|
|
183
|
+
const yearInfo = computed(() =>
|
|
184
|
+
props.years.find(
|
|
185
|
+
(item) => String(item.year) === shownMonth.value.slice(0, 4),
|
|
186
|
+
),
|
|
187
|
+
);
|
|
188
|
+
const yearText = computed(() => ysCalendarYearText(yearInfo.value));
|
|
189
|
+
const yearTitle = computed(() => {
|
|
190
|
+
const info = yearInfo.value;
|
|
191
|
+
if (!info) return "";
|
|
192
|
+
const lines = [`${info.year} 年:${yearText.value}`];
|
|
193
|
+
for (const check of info.checks ?? []) {
|
|
194
|
+
const head = `${check.label || check.source}:${check.status_label || check.status}`;
|
|
195
|
+
lines.push(check.message ? `${head}(${check.message})` : head);
|
|
196
|
+
for (const line of (check.differences ?? []).slice(0, 5))
|
|
197
|
+
lines.push(` ${line}`);
|
|
198
|
+
}
|
|
199
|
+
return lines.join("\n");
|
|
200
|
+
});
|
|
201
|
+
const yearTone = computed(() => {
|
|
202
|
+
const info = yearInfo.value;
|
|
203
|
+
if (!info || info.status === "unpublished" || info.status === "unknown")
|
|
204
|
+
return "warning";
|
|
205
|
+
if (info.checks?.some((item) => item.status === "differ")) return "warning";
|
|
206
|
+
return info.verified ? "success" : "info";
|
|
207
|
+
});
|
|
170
208
|
const todayVisible = computed(() =>
|
|
171
209
|
cells.value.some((cell) => cell.date === todayText.value),
|
|
172
210
|
);
|
|
@@ -238,16 +276,31 @@ function isWeekendCell(cell: YsMonthCell): boolean {
|
|
|
238
276
|
if (value) return value === "weekend" || value === "holiday";
|
|
239
277
|
return cell.weekday >= 5;
|
|
240
278
|
}
|
|
241
|
-
/** 状态标签下面那一行:节日名;交易日视图休市日写「国庆节 ·
|
|
279
|
+
/** 状态标签下面那一行:节日名;交易日视图休市日写「国庆节 · 休市」,法定补班写「国庆节调休」,
|
|
280
|
+
* 交易所额外休市写「交易所休市」,夜盘视图下没有夜盘的交易日写「无夜盘」。 */
|
|
242
281
|
function subline(date: string): string {
|
|
243
282
|
if (!inShownMonth(date)) return "";
|
|
244
283
|
const value = status(date);
|
|
245
|
-
const
|
|
284
|
+
const item = info(date);
|
|
285
|
+
const name = item?.name ?? "";
|
|
286
|
+
if (value && item?.market_closed) return "交易所休市";
|
|
287
|
+
if (value === "trading" && props.night && item?.night_session === false)
|
|
288
|
+
return "无夜盘";
|
|
246
289
|
if (!value || !name) return "";
|
|
247
290
|
if (value === "closed") return `${name} · ${labelText.value.closed}`;
|
|
248
291
|
if (value === "adjusted") return `${name}调休`;
|
|
249
292
|
return name;
|
|
250
293
|
}
|
|
294
|
+
/** 夜盘视图下当晚有夜盘的交易日。 */
|
|
295
|
+
function hasNight(date: string): boolean {
|
|
296
|
+
return (
|
|
297
|
+
props.night &&
|
|
298
|
+
tradingView.value &&
|
|
299
|
+
inShownMonth(date) &&
|
|
300
|
+
status(date) === "trading" &&
|
|
301
|
+
info(date)?.night_session === true
|
|
302
|
+
);
|
|
303
|
+
}
|
|
251
304
|
function ordinalOf(date: string): number | undefined {
|
|
252
305
|
return props.showOrdinal && inShownMonth(date)
|
|
253
306
|
? marks.value.get(date)?.ordinal
|
|
@@ -269,6 +322,7 @@ function ariaLabel(cell: YsMonthCell): string {
|
|
|
269
322
|
? `${YS_DAY_KIND_LABELS[item.kind]} ${item.name}`
|
|
270
323
|
: YS_DAY_KIND_LABELS[item.kind],
|
|
271
324
|
);
|
|
325
|
+
if (item.market_closed) parts.push(`交易所休市(${item.market_closed})`);
|
|
272
326
|
if (tradingView.value) {
|
|
273
327
|
const mark = markOf(cell.date);
|
|
274
328
|
parts.push(
|
|
@@ -278,6 +332,12 @@ function ariaLabel(cell: YsMonthCell): string {
|
|
|
278
332
|
: "交易日"
|
|
279
333
|
: "休市",
|
|
280
334
|
);
|
|
335
|
+
if (props.night && item.trading && item.night_session != null)
|
|
336
|
+
parts.push(
|
|
337
|
+
item.night_session
|
|
338
|
+
? `当晚有夜盘,归属 ${item.night_trading_day ?? ""}`
|
|
339
|
+
: "当晚没有夜盘",
|
|
340
|
+
);
|
|
281
341
|
for (const tag of mark?.tags ?? [])
|
|
282
342
|
parts.push(YS_TRADING_TAG_LABELS[tag].full);
|
|
283
343
|
}
|
|
@@ -294,7 +354,10 @@ const legendItems = computed<{ key: YsCalendarStatus; text: string }[]>(() => {
|
|
|
294
354
|
if (tradingView.value)
|
|
295
355
|
return [
|
|
296
356
|
{ key: "trading", text: props.showOrdinal ? "旁边是本月第几个" : "" },
|
|
297
|
-
{
|
|
357
|
+
{
|
|
358
|
+
key: "closed",
|
|
359
|
+
text: `周末、放假、交易所休市和${labelText.value.adjusted}的周末`,
|
|
360
|
+
},
|
|
298
361
|
];
|
|
299
362
|
if (view.value === "work")
|
|
300
363
|
return [
|
|
@@ -455,6 +518,14 @@ function goToday() {
|
|
|
455
518
|
><strong>{{ part.value }}</strong></span
|
|
456
519
|
>
|
|
457
520
|
</div>
|
|
521
|
+
<span
|
|
522
|
+
v-if="yearText && !small"
|
|
523
|
+
class="ys-calendar__source"
|
|
524
|
+
:class="`is-${yearTone}`"
|
|
525
|
+
:title="yearTitle"
|
|
526
|
+
role="note"
|
|
527
|
+
>{{ shownMonth.slice(0, 4) }} 年:{{ yearText }}</span
|
|
528
|
+
>
|
|
458
529
|
<div v-if="$slots.extra" class="ys-calendar__extra">
|
|
459
530
|
<slot name="extra" />
|
|
460
531
|
</div>
|
|
@@ -543,6 +614,7 @@ function goToday() {
|
|
|
543
614
|
v-else-if="
|
|
544
615
|
!small &&
|
|
545
616
|
(ordinalOf(cell.date) ||
|
|
617
|
+
hasNight(cell.date) ||
|
|
546
618
|
(showLabel && statusLabel(cell.date)))
|
|
547
619
|
"
|
|
548
620
|
class="ys-calendar__status"
|
|
@@ -553,6 +625,12 @@ function goToday() {
|
|
|
553
625
|
aria-hidden="true"
|
|
554
626
|
>第 {{ ordinalOf(cell.date) }} 个</span
|
|
555
627
|
>
|
|
628
|
+
<span
|
|
629
|
+
v-if="hasNight(cell.date)"
|
|
630
|
+
class="ys-calendar__night"
|
|
631
|
+
aria-hidden="true"
|
|
632
|
+
>夜</span
|
|
633
|
+
>
|
|
556
634
|
<span
|
|
557
635
|
v-if="showLabel && statusLabel(cell.date)"
|
|
558
636
|
class="ys-calendar__label"
|
|
@@ -617,6 +695,9 @@ function goToday() {
|
|
|
617
695
|
item.text
|
|
618
696
|
}}</span>
|
|
619
697
|
</button>
|
|
698
|
+
<span v-if="night && tradingView" class="ys-calendar__legend-night"
|
|
699
|
+
><i class="ys-calendar__night">夜</i>当晚有期货夜盘</span
|
|
700
|
+
>
|
|
620
701
|
<span v-if="todayVisible" class="ys-calendar__legend-today">今天</span>
|
|
621
702
|
</footer>
|
|
622
703
|
</div>
|
|
@@ -711,6 +792,53 @@ function goToday() {
|
|
|
711
792
|
font-size: 14px;
|
|
712
793
|
font-variant-numeric: tabular-nums;
|
|
713
794
|
}
|
|
795
|
+
.ys-calendar__source {
|
|
796
|
+
padding: 1px 8px;
|
|
797
|
+
border-radius: var(--ys-radius-s);
|
|
798
|
+
color: var(--ys-color-text-2);
|
|
799
|
+
background: color-mix(in srgb, var(--ys-color-text-3) 10%, transparent);
|
|
800
|
+
font-size: 12px;
|
|
801
|
+
line-height: 20px;
|
|
802
|
+
cursor: help;
|
|
803
|
+
}
|
|
804
|
+
.ys-calendar__source.is-success {
|
|
805
|
+
color: color-mix(
|
|
806
|
+
in srgb,
|
|
807
|
+
var(--ys-color-success) 80%,
|
|
808
|
+
var(--ys-color-text-1)
|
|
809
|
+
);
|
|
810
|
+
background: color-mix(in srgb, var(--ys-color-success) 10%, transparent);
|
|
811
|
+
}
|
|
812
|
+
.ys-calendar__source.is-warning {
|
|
813
|
+
color: color-mix(
|
|
814
|
+
in srgb,
|
|
815
|
+
var(--ys-color-warning) 80%,
|
|
816
|
+
var(--ys-color-text-1)
|
|
817
|
+
);
|
|
818
|
+
background: color-mix(in srgb, var(--ys-color-warning) 12%, transparent);
|
|
819
|
+
}
|
|
820
|
+
/* 夜盘角标:小号描边「夜」,不抢交易日标签 */
|
|
821
|
+
.ys-calendar__night {
|
|
822
|
+
flex: none;
|
|
823
|
+
padding: 0 3px;
|
|
824
|
+
border: 1px solid color-mix(in srgb, var(--ys-color-primary) 45%, transparent);
|
|
825
|
+
border-radius: var(--ys-radius-s);
|
|
826
|
+
color: color-mix(
|
|
827
|
+
in srgb,
|
|
828
|
+
var(--ys-color-primary) 85%,
|
|
829
|
+
var(--ys-color-text-1)
|
|
830
|
+
);
|
|
831
|
+
font-size: 10px;
|
|
832
|
+
font-style: normal;
|
|
833
|
+
font-weight: 600;
|
|
834
|
+
line-height: 14px;
|
|
835
|
+
}
|
|
836
|
+
.ys-calendar__legend-night {
|
|
837
|
+
display: inline-flex;
|
|
838
|
+
gap: 5px;
|
|
839
|
+
align-items: center;
|
|
840
|
+
margin-left: 6px;
|
|
841
|
+
}
|
|
714
842
|
.ys-calendar__extra {
|
|
715
843
|
display: flex;
|
|
716
844
|
flex-wrap: wrap;
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
* - 本月位置:几月第 N 个工作日、第 N 个交易日(带进度条),放假时写「国庆节假期第 3 天,共 8 天」。
|
|
9
9
|
* - 当天的事项(events),以及默认插槽放页面自己的内容(如上一个、下一个交易日和 T+N 推算)。
|
|
10
10
|
* - 农历、传统节日和节气默认不显示(lunar 打开);农历用 ysLunar 现算,只用于显示。
|
|
11
|
+
* - 交易所额外休市(国务院安排上班、交易所休市)写「交易所休市」和原因;交易日写当晚有没有期货夜盘、夜盘归属哪个交易日
|
|
12
|
+
* (night 关掉不写)。
|
|
13
|
+
* - years 传了就在底部写这一天所在年份的数据来源与核对状态。
|
|
11
14
|
* - 数据都由 @ysgroup/core 的 ysDayDetail 从服务端下发的 days 推出,组件只显示。
|
|
12
15
|
*/
|
|
13
16
|
import { computed } from "vue";
|
|
@@ -19,7 +22,9 @@ import {
|
|
|
19
22
|
ysIsDate,
|
|
20
23
|
ysToday,
|
|
21
24
|
ysWeekdayLabel,
|
|
25
|
+
ysCalendarYearText,
|
|
22
26
|
type YsCalendarDay,
|
|
27
|
+
type YsCalendarYearInfo,
|
|
23
28
|
} from "@ysgroup/core";
|
|
24
29
|
import type {
|
|
25
30
|
YsCalendarEvent,
|
|
@@ -50,6 +55,10 @@ const props = withDefaults(
|
|
|
50
55
|
trading?: boolean;
|
|
51
56
|
/** 显示农历、干支生肖、传统节日和节气;默认不显示。 */
|
|
52
57
|
lunar?: boolean;
|
|
58
|
+
/** 交易日写当晚有没有期货夜盘(trading 关掉时也不写)。 */
|
|
59
|
+
night?: boolean;
|
|
60
|
+
/** 各年数据来源与核对状态(服务端 CalendarService.year_states())。 */
|
|
61
|
+
years?: readonly YsCalendarYearInfo[];
|
|
53
62
|
}>(),
|
|
54
63
|
{
|
|
55
64
|
days: () => [],
|
|
@@ -58,6 +67,8 @@ const props = withDefaults(
|
|
|
58
67
|
labels: () => ({}),
|
|
59
68
|
trading: true,
|
|
60
69
|
lunar: false,
|
|
70
|
+
night: true,
|
|
71
|
+
years: () => [],
|
|
61
72
|
},
|
|
62
73
|
);
|
|
63
74
|
|
|
@@ -126,12 +137,20 @@ const chips = computed(() => {
|
|
|
126
137
|
tone: "holiday",
|
|
127
138
|
});
|
|
128
139
|
else list.push({ text: labels[kind], tone: kind });
|
|
140
|
+
if (info.value.market_closed)
|
|
141
|
+
list.push({ text: "交易所休市", tone: "holiday" });
|
|
129
142
|
if (props.trading) {
|
|
130
143
|
list.push(
|
|
131
144
|
info.value.trading
|
|
132
145
|
? { text: labels.trading, tone: "trading" }
|
|
133
146
|
: { text: labels.closed, tone: "closed" },
|
|
134
147
|
);
|
|
148
|
+
if (props.night && info.value.trading && info.value.night_session != null)
|
|
149
|
+
list.push(
|
|
150
|
+
info.value.night_session
|
|
151
|
+
? { text: "当晚有夜盘", tone: "trading" }
|
|
152
|
+
: { text: "当晚无夜盘", tone: "key" },
|
|
153
|
+
);
|
|
135
154
|
for (const tag of detail.value.tags)
|
|
136
155
|
list.push({ text: YS_TRADING_TAG_LABELS[tag].full, tone: "key" });
|
|
137
156
|
}
|
|
@@ -176,9 +195,30 @@ const note = computed(() => {
|
|
|
176
195
|
if (!info.value) return "";
|
|
177
196
|
if (props.trading && info.value.kind === "adjusted")
|
|
178
197
|
return "法定补班的周末要上班,但交易所照常休市,不是交易日。";
|
|
198
|
+
if (info.value.market_closed)
|
|
199
|
+
return `国务院安排这天上班,但交易所休市:${info.value.market_closed}。`;
|
|
200
|
+
if (
|
|
201
|
+
props.trading &&
|
|
202
|
+
props.night &&
|
|
203
|
+
info.value.night_session &&
|
|
204
|
+
info.value.night_trading_day
|
|
205
|
+
)
|
|
206
|
+
return `当晚 21:00 起的夜盘归属 ${info.value.night_trading_day} 交易日。`;
|
|
207
|
+
if (
|
|
208
|
+
props.trading &&
|
|
209
|
+
props.night &&
|
|
210
|
+
info.value.trading &&
|
|
211
|
+
info.value.night_session === null
|
|
212
|
+
)
|
|
213
|
+
return "下一个交易日所在年份还没有安排,暂不判断当晚有没有夜盘。";
|
|
179
214
|
return "";
|
|
180
215
|
});
|
|
181
216
|
|
|
217
|
+
const yearInfo = computed(() =>
|
|
218
|
+
props.years.find((item) => String(item.year) === props.date.slice(0, 4)),
|
|
219
|
+
);
|
|
220
|
+
const sourceText = computed(() => ysCalendarYearText(yearInfo.value));
|
|
221
|
+
|
|
182
222
|
const dayEvents = computed(() =>
|
|
183
223
|
props.events.filter((item) => item.date === props.date),
|
|
184
224
|
);
|
|
@@ -278,6 +318,10 @@ const dayEvents = computed(() =>
|
|
|
278
318
|
<div v-if="$slots.default" class="ys-day-card__extra">
|
|
279
319
|
<slot :detail="detail" />
|
|
280
320
|
</div>
|
|
321
|
+
|
|
322
|
+
<p v-if="sourceText" class="ys-day-card__source">
|
|
323
|
+
数据来源:{{ sourceText }}
|
|
324
|
+
</p>
|
|
281
325
|
</template>
|
|
282
326
|
<p v-else class="ys-day-card__empty">
|
|
283
327
|
点月历里的一天,这里显示当天的详情。
|
|
@@ -546,6 +590,11 @@ const dayEvents = computed(() =>
|
|
|
546
590
|
.ys-day-card__events li.is-info {
|
|
547
591
|
--chip: var(--ys-color-text-3);
|
|
548
592
|
}
|
|
593
|
+
.ys-day-card__source {
|
|
594
|
+
margin: 0;
|
|
595
|
+
color: var(--ys-color-text-3);
|
|
596
|
+
font-size: 12px;
|
|
597
|
+
}
|
|
549
598
|
.ys-day-card__extra {
|
|
550
599
|
padding-top: 12px;
|
|
551
600
|
border-top: 1px dashed var(--ys-color-border);
|