@sanguo-dev/calendar-ui 0.0.2 → 0.0.3
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/README.md +194 -194
- package/package.json +61 -61
- package/src/calendar.ts +785 -785
- package/src/components/day.ts +79 -79
- package/src/components/grid.ts +181 -181
- package/src/components/header.ts +69 -69
- package/src/components/nav.ts +20 -20
- package/src/components/weekdays.ts +19 -19
- package/src/index.ts +26 -26
- package/src/locales/en-US.ts +28 -28
- package/src/locales/index.ts +19 -19
- package/src/locales/zh-CN.ts +13 -13
- package/src/style.css +388 -388
- package/src/types/calendar.ts +267 -267
- package/src/types/components.ts +69 -69
- package/src/types/index.ts +32 -32
- package/src/types/locale.ts +26 -26
- package/src/types/utils.ts +28 -28
- package/src/utils/date.ts +82 -82
- package/src/utils/days.ts +88 -88
- package/src/utils/dom.ts +11 -11
- package/src/utils/motion.ts +39 -39
package/src/style.css
CHANGED
|
@@ -1,388 +1,388 @@
|
|
|
1
|
-
/* calendar-ui 的默认皮肤:所有颜色/尺寸都走 CSS 变量,外部改 .cui 即可换主题 */
|
|
2
|
-
.cui {
|
|
3
|
-
--cui-bg: #ffffff;
|
|
4
|
-
--cui-fg: #1f2328;
|
|
5
|
-
--cui-muted: #8b949e;
|
|
6
|
-
--cui-border: #e6e8eb;
|
|
7
|
-
--cui-accent: #2563eb;
|
|
8
|
-
--cui-accent-fg: #ffffff;
|
|
9
|
-
--cui-rest: #e5484d;
|
|
10
|
-
--cui-hover: #f3f4f6;
|
|
11
|
-
--cui-radius: 10px;
|
|
12
|
-
|
|
13
|
-
color-scheme: light;
|
|
14
|
-
box-sizing: border-box;
|
|
15
|
-
width: 100%;
|
|
16
|
-
max-width: 420px;
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
padding: 12px;
|
|
19
|
-
border: 1px solid var(--cui-border);
|
|
20
|
-
border-radius: var(--cui-radius);
|
|
21
|
-
background: var(--cui-bg);
|
|
22
|
-
color: var(--cui-fg);
|
|
23
|
-
font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
24
|
-
font-size: 14px;
|
|
25
|
-
line-height: 1.4;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* 双月范围视图 */
|
|
29
|
-
.cui--range {
|
|
30
|
-
max-width: 900px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.cui__months {
|
|
34
|
-
display: grid;
|
|
35
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
36
|
-
gap: 16px;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.cui__month {
|
|
40
|
-
min-width: 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@media (max-width: 720px) {
|
|
44
|
-
.cui__months {
|
|
45
|
-
grid-template-columns: minmax(0, 1fr);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/* 显式深色 */
|
|
50
|
-
.cui[data-theme="dark"] {
|
|
51
|
-
--cui-bg: #161b22;
|
|
52
|
-
--cui-fg: #e6edf3;
|
|
53
|
-
--cui-muted: #8b949e;
|
|
54
|
-
--cui-border: #30363d;
|
|
55
|
-
--cui-accent: #1f6feb;
|
|
56
|
-
--cui-accent-fg: #ffffff;
|
|
57
|
-
--cui-rest: #ff7b72;
|
|
58
|
-
--cui-hover: #21262d;
|
|
59
|
-
|
|
60
|
-
color-scheme: dark;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/* auto:优先跟随最近的 data-theme="dark" */
|
|
64
|
-
[data-theme="dark"] .cui[data-theme="auto"] {
|
|
65
|
-
--cui-bg: #161b22;
|
|
66
|
-
--cui-fg: #e6edf3;
|
|
67
|
-
--cui-muted: #8b949e;
|
|
68
|
-
--cui-border: #30363d;
|
|
69
|
-
--cui-accent: #1f6feb;
|
|
70
|
-
--cui-accent-fg: #ffffff;
|
|
71
|
-
--cui-rest: #ff7b72;
|
|
72
|
-
--cui-hover: #21262d;
|
|
73
|
-
|
|
74
|
-
color-scheme: dark;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/* auto 且没有 data-theme 时跟随系统 */
|
|
78
|
-
@media (prefers-color-scheme: dark) {
|
|
79
|
-
.cui[data-theme="auto"] {
|
|
80
|
-
--cui-bg: #161b22;
|
|
81
|
-
--cui-fg: #e6edf3;
|
|
82
|
-
--cui-muted: #8b949e;
|
|
83
|
-
--cui-border: #30363d;
|
|
84
|
-
--cui-accent: #1f6feb;
|
|
85
|
-
--cui-accent-fg: #ffffff;
|
|
86
|
-
--cui-rest: #ff7b72;
|
|
87
|
-
--cui-hover: #21262d;
|
|
88
|
-
|
|
89
|
-
color-scheme: dark;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/* 外层明确 light 时,系统深色不覆盖 */
|
|
93
|
-
[data-theme="light"] .cui[data-theme="auto"] {
|
|
94
|
-
--cui-bg: #ffffff;
|
|
95
|
-
--cui-fg: #1f2328;
|
|
96
|
-
--cui-muted: #8b949e;
|
|
97
|
-
--cui-border: #e6e8eb;
|
|
98
|
-
--cui-accent: #2563eb;
|
|
99
|
-
--cui-accent-fg: #ffffff;
|
|
100
|
-
--cui-rest: #e5484d;
|
|
101
|
-
--cui-hover: #f3f4f6;
|
|
102
|
-
|
|
103
|
-
color-scheme: light;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.cui *,
|
|
108
|
-
.cui *::before,
|
|
109
|
-
.cui *::after {
|
|
110
|
-
box-sizing: border-box;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/* 头部:上个月 / 年月标题 / 下个月 */
|
|
114
|
-
.cui__header {
|
|
115
|
-
display: flex;
|
|
116
|
-
align-items: center;
|
|
117
|
-
justify-content: space-between;
|
|
118
|
-
gap: 8px;
|
|
119
|
-
padding: 4px 2px 10px;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.cui__title {
|
|
123
|
-
font-weight: 600;
|
|
124
|
-
font-size: 15px;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.cui__nav {
|
|
128
|
-
width: 30px;
|
|
129
|
-
height: 30px;
|
|
130
|
-
border: 1px solid var(--cui-border);
|
|
131
|
-
border-radius: 8px;
|
|
132
|
-
background: transparent;
|
|
133
|
-
color: var(--cui-fg);
|
|
134
|
-
font-size: 16px;
|
|
135
|
-
line-height: 1;
|
|
136
|
-
cursor: pointer;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.cui__nav:hover {
|
|
140
|
-
background: var(--cui-hover);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.cui__nav:disabled {
|
|
144
|
-
opacity: 0.45;
|
|
145
|
-
cursor: not-allowed;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.cui__nav:disabled:hover {
|
|
149
|
-
background: transparent;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.cui__nav:focus-visible,
|
|
153
|
-
.cui__day:focus-visible {
|
|
154
|
-
outline: 2px solid var(--cui-accent);
|
|
155
|
-
outline-offset: 1px;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/* 星期表头 */
|
|
159
|
-
.cui__weekdays {
|
|
160
|
-
display: grid;
|
|
161
|
-
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
162
|
-
gap: 4px;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/* 6 行日期;折叠时按行收起,节点仍然复用 */
|
|
166
|
-
.cui__grid {
|
|
167
|
-
display: flex;
|
|
168
|
-
flex-direction: column;
|
|
169
|
-
gap: 0;
|
|
170
|
-
contain: layout paint;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
.cui__week {
|
|
174
|
-
display: grid;
|
|
175
|
-
min-height: 0;
|
|
176
|
-
margin-bottom: 4px;
|
|
177
|
-
overflow: hidden;
|
|
178
|
-
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
179
|
-
gap: 4px;
|
|
180
|
-
opacity: 1;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
.cui__week:last-child {
|
|
184
|
-
margin-bottom: 0;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/* 折叠动画由 JS 按真实行高驱动(见 components/grid.ts),这里只负责最终状态 */
|
|
188
|
-
.cui__week.is-collapsed-hidden {
|
|
189
|
-
height: 0;
|
|
190
|
-
margin-bottom: 0;
|
|
191
|
-
opacity: 0;
|
|
192
|
-
pointer-events: none;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
.cui__week[hidden] {
|
|
196
|
-
display: none;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
.cui__viewport {
|
|
200
|
-
position: relative;
|
|
201
|
-
min-width: 0;
|
|
202
|
-
overflow: hidden;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.cui__grid.is-month-clone {
|
|
206
|
-
position: absolute;
|
|
207
|
-
inset: 0;
|
|
208
|
-
pointer-events: none;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/* 只在动画期间提升为合成层,动画结束后随类名一起移除 */
|
|
212
|
-
.cui__grid.is-month-clone,
|
|
213
|
-
.cui__grid.is-month-in-next,
|
|
214
|
-
.cui__grid.is-month-in-prev {
|
|
215
|
-
will-change: transform;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
.cui--no-animation .cui__grid,
|
|
219
|
-
.cui--no-animation .cui__week {
|
|
220
|
-
transition: none;
|
|
221
|
-
animation: none;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
@media (prefers-reduced-motion: reduce) {
|
|
225
|
-
.cui__grid,
|
|
226
|
-
.cui__week {
|
|
227
|
-
transition: none;
|
|
228
|
-
animation: none;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.cui__weekday {
|
|
233
|
-
padding: 4px 0;
|
|
234
|
-
color: var(--cui-muted);
|
|
235
|
-
font-size: 12px;
|
|
236
|
-
text-align: center;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/* 日期格 */
|
|
240
|
-
.cui__day {
|
|
241
|
-
position: relative;
|
|
242
|
-
display: flex;
|
|
243
|
-
flex-direction: column;
|
|
244
|
-
align-items: center;
|
|
245
|
-
justify-content: center;
|
|
246
|
-
gap: 2px;
|
|
247
|
-
min-height: 46px;
|
|
248
|
-
padding: 4px 2px;
|
|
249
|
-
border: 1px solid transparent;
|
|
250
|
-
border-radius: 8px;
|
|
251
|
-
background: transparent;
|
|
252
|
-
color: inherit;
|
|
253
|
-
font: inherit;
|
|
254
|
-
cursor: pointer;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.cui__day:hover {
|
|
258
|
-
background: var(--cui-hover);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.cui__day-num {
|
|
262
|
-
font-size: 15px;
|
|
263
|
-
font-weight: 500;
|
|
264
|
-
line-height: 1.1;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/* 周末:日期数字固定用节假日红(--cui-rest),不由节假日数据决定 */
|
|
268
|
-
.cui__day.is-weekend .cui__day-num {
|
|
269
|
-
color: var(--cui-rest);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/* 选中时数字跟随反白色,避免红底红字 */
|
|
273
|
-
.cui__day.is-selected .cui__day-num {
|
|
274
|
-
color: currentColor;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
.cui__day-sub {
|
|
278
|
-
max-width: 100%;
|
|
279
|
-
overflow: hidden;
|
|
280
|
-
color: var(--cui-muted);
|
|
281
|
-
font-size: 11px;
|
|
282
|
-
white-space: nowrap;
|
|
283
|
-
text-overflow: ellipsis;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/* 左上角的休 / 班标记 */
|
|
287
|
-
.cui__day-tag {
|
|
288
|
-
position: absolute;
|
|
289
|
-
top: 3px;
|
|
290
|
-
left: 4px;
|
|
291
|
-
font-size: 10px;
|
|
292
|
-
font-weight: 600;
|
|
293
|
-
line-height: 1;
|
|
294
|
-
pointer-events: none;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
.cui__day-tag[hidden] {
|
|
298
|
-
display: none;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
.cui__day-tag[data-tone="rest"] {
|
|
302
|
-
color: var(--cui-rest);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
.cui__day-tag[data-tone="work"] {
|
|
306
|
-
color: var(--cui-accent);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.cui__day.is-selected .cui__day-tag {
|
|
310
|
-
color: currentColor;
|
|
311
|
-
opacity: 0.9;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/* 状态 */
|
|
315
|
-
.cui__day.is-outside {
|
|
316
|
-
opacity: 0.35;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
.cui__day.is-disabled,
|
|
320
|
-
.cui__day:disabled {
|
|
321
|
-
opacity: 0.35;
|
|
322
|
-
cursor: not-allowed;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
.cui__day.is-disabled:hover,
|
|
326
|
-
.cui__day:disabled:hover {
|
|
327
|
-
background: transparent;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
.cui__day[data-tone="rest"] .cui__day-sub {
|
|
331
|
-
color: var(--cui-rest);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
.cui__day.is-today {
|
|
335
|
-
border-color: var(--cui-accent);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
.cui__day.is-selected {
|
|
339
|
-
background: var(--cui-accent);
|
|
340
|
-
color: var(--cui-accent-fg);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
.cui__day.is-in-range:not(.is-selected) {
|
|
344
|
-
background: color-mix(in srgb, var(--cui-accent) 14%, transparent);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
.cui__day.is-in-range:hover:not(.is-selected) {
|
|
348
|
-
background: color-mix(in srgb, var(--cui-accent) 22%, transparent);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
.cui__day.is-selected .cui__day-sub {
|
|
352
|
-
color: currentColor;
|
|
353
|
-
opacity: 0.85;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/* 折叠开关:始终只有一个按钮,箭头随状态切换 */
|
|
357
|
-
.cui__collapse {
|
|
358
|
-
display: flex;
|
|
359
|
-
width: 100%;
|
|
360
|
-
align-items: center;
|
|
361
|
-
justify-content: center;
|
|
362
|
-
margin-top: 8px;
|
|
363
|
-
padding: 2px 0;
|
|
364
|
-
border: 0;
|
|
365
|
-
border-radius: 6px;
|
|
366
|
-
background: transparent;
|
|
367
|
-
color: var(--cui-muted);
|
|
368
|
-
font: inherit;
|
|
369
|
-
font-size: 14px;
|
|
370
|
-
line-height: 1;
|
|
371
|
-
cursor: pointer;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
.cui__collapse:hover {
|
|
375
|
-
color: var(--cui-fg);
|
|
376
|
-
background: var(--cui-hover);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
.cui__collapse:focus-visible {
|
|
380
|
-
outline: 2px solid var(--cui-accent);
|
|
381
|
-
outline-offset: 1px;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/* 隐藏状态:类选择器里的 display 会盖掉 [hidden] 的默认样式,这里显式补上 */
|
|
385
|
-
.cui[hidden],
|
|
386
|
-
.cui__header[hidden] {
|
|
387
|
-
display: none;
|
|
388
|
-
}
|
|
1
|
+
/* calendar-ui 的默认皮肤:所有颜色/尺寸都走 CSS 变量,外部改 .cui 即可换主题 */
|
|
2
|
+
.cui {
|
|
3
|
+
--cui-bg: #ffffff;
|
|
4
|
+
--cui-fg: #1f2328;
|
|
5
|
+
--cui-muted: #8b949e;
|
|
6
|
+
--cui-border: #e6e8eb;
|
|
7
|
+
--cui-accent: #2563eb;
|
|
8
|
+
--cui-accent-fg: #ffffff;
|
|
9
|
+
--cui-rest: #e5484d;
|
|
10
|
+
--cui-hover: #f3f4f6;
|
|
11
|
+
--cui-radius: 10px;
|
|
12
|
+
|
|
13
|
+
color-scheme: light;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
width: 100%;
|
|
16
|
+
max-width: 420px;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
padding: 12px;
|
|
19
|
+
border: 1px solid var(--cui-border);
|
|
20
|
+
border-radius: var(--cui-radius);
|
|
21
|
+
background: var(--cui-bg);
|
|
22
|
+
color: var(--cui-fg);
|
|
23
|
+
font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
24
|
+
font-size: 14px;
|
|
25
|
+
line-height: 1.4;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* 双月范围视图 */
|
|
29
|
+
.cui--range {
|
|
30
|
+
max-width: 900px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.cui__months {
|
|
34
|
+
display: grid;
|
|
35
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
36
|
+
gap: 16px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.cui__month {
|
|
40
|
+
min-width: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@media (max-width: 720px) {
|
|
44
|
+
.cui__months {
|
|
45
|
+
grid-template-columns: minmax(0, 1fr);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* 显式深色 */
|
|
50
|
+
.cui[data-theme="dark"] {
|
|
51
|
+
--cui-bg: #161b22;
|
|
52
|
+
--cui-fg: #e6edf3;
|
|
53
|
+
--cui-muted: #8b949e;
|
|
54
|
+
--cui-border: #30363d;
|
|
55
|
+
--cui-accent: #1f6feb;
|
|
56
|
+
--cui-accent-fg: #ffffff;
|
|
57
|
+
--cui-rest: #ff7b72;
|
|
58
|
+
--cui-hover: #21262d;
|
|
59
|
+
|
|
60
|
+
color-scheme: dark;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* auto:优先跟随最近的 data-theme="dark" */
|
|
64
|
+
[data-theme="dark"] .cui[data-theme="auto"] {
|
|
65
|
+
--cui-bg: #161b22;
|
|
66
|
+
--cui-fg: #e6edf3;
|
|
67
|
+
--cui-muted: #8b949e;
|
|
68
|
+
--cui-border: #30363d;
|
|
69
|
+
--cui-accent: #1f6feb;
|
|
70
|
+
--cui-accent-fg: #ffffff;
|
|
71
|
+
--cui-rest: #ff7b72;
|
|
72
|
+
--cui-hover: #21262d;
|
|
73
|
+
|
|
74
|
+
color-scheme: dark;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* auto 且没有 data-theme 时跟随系统 */
|
|
78
|
+
@media (prefers-color-scheme: dark) {
|
|
79
|
+
.cui[data-theme="auto"] {
|
|
80
|
+
--cui-bg: #161b22;
|
|
81
|
+
--cui-fg: #e6edf3;
|
|
82
|
+
--cui-muted: #8b949e;
|
|
83
|
+
--cui-border: #30363d;
|
|
84
|
+
--cui-accent: #1f6feb;
|
|
85
|
+
--cui-accent-fg: #ffffff;
|
|
86
|
+
--cui-rest: #ff7b72;
|
|
87
|
+
--cui-hover: #21262d;
|
|
88
|
+
|
|
89
|
+
color-scheme: dark;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* 外层明确 light 时,系统深色不覆盖 */
|
|
93
|
+
[data-theme="light"] .cui[data-theme="auto"] {
|
|
94
|
+
--cui-bg: #ffffff;
|
|
95
|
+
--cui-fg: #1f2328;
|
|
96
|
+
--cui-muted: #8b949e;
|
|
97
|
+
--cui-border: #e6e8eb;
|
|
98
|
+
--cui-accent: #2563eb;
|
|
99
|
+
--cui-accent-fg: #ffffff;
|
|
100
|
+
--cui-rest: #e5484d;
|
|
101
|
+
--cui-hover: #f3f4f6;
|
|
102
|
+
|
|
103
|
+
color-scheme: light;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.cui *,
|
|
108
|
+
.cui *::before,
|
|
109
|
+
.cui *::after {
|
|
110
|
+
box-sizing: border-box;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* 头部:上个月 / 年月标题 / 下个月 */
|
|
114
|
+
.cui__header {
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: space-between;
|
|
118
|
+
gap: 8px;
|
|
119
|
+
padding: 4px 2px 10px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.cui__title {
|
|
123
|
+
font-weight: 600;
|
|
124
|
+
font-size: 15px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.cui__nav {
|
|
128
|
+
width: 30px;
|
|
129
|
+
height: 30px;
|
|
130
|
+
border: 1px solid var(--cui-border);
|
|
131
|
+
border-radius: 8px;
|
|
132
|
+
background: transparent;
|
|
133
|
+
color: var(--cui-fg);
|
|
134
|
+
font-size: 16px;
|
|
135
|
+
line-height: 1;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.cui__nav:hover {
|
|
140
|
+
background: var(--cui-hover);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.cui__nav:disabled {
|
|
144
|
+
opacity: 0.45;
|
|
145
|
+
cursor: not-allowed;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.cui__nav:disabled:hover {
|
|
149
|
+
background: transparent;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.cui__nav:focus-visible,
|
|
153
|
+
.cui__day:focus-visible {
|
|
154
|
+
outline: 2px solid var(--cui-accent);
|
|
155
|
+
outline-offset: 1px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* 星期表头 */
|
|
159
|
+
.cui__weekdays {
|
|
160
|
+
display: grid;
|
|
161
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
162
|
+
gap: 4px;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* 6 行日期;折叠时按行收起,节点仍然复用 */
|
|
166
|
+
.cui__grid {
|
|
167
|
+
display: flex;
|
|
168
|
+
flex-direction: column;
|
|
169
|
+
gap: 0;
|
|
170
|
+
contain: layout paint;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.cui__week {
|
|
174
|
+
display: grid;
|
|
175
|
+
min-height: 0;
|
|
176
|
+
margin-bottom: 4px;
|
|
177
|
+
overflow: hidden;
|
|
178
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
179
|
+
gap: 4px;
|
|
180
|
+
opacity: 1;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.cui__week:last-child {
|
|
184
|
+
margin-bottom: 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* 折叠动画由 JS 按真实行高驱动(见 components/grid.ts),这里只负责最终状态 */
|
|
188
|
+
.cui__week.is-collapsed-hidden {
|
|
189
|
+
height: 0;
|
|
190
|
+
margin-bottom: 0;
|
|
191
|
+
opacity: 0;
|
|
192
|
+
pointer-events: none;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.cui__week[hidden] {
|
|
196
|
+
display: none;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.cui__viewport {
|
|
200
|
+
position: relative;
|
|
201
|
+
min-width: 0;
|
|
202
|
+
overflow: hidden;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.cui__grid.is-month-clone {
|
|
206
|
+
position: absolute;
|
|
207
|
+
inset: 0;
|
|
208
|
+
pointer-events: none;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* 只在动画期间提升为合成层,动画结束后随类名一起移除 */
|
|
212
|
+
.cui__grid.is-month-clone,
|
|
213
|
+
.cui__grid.is-month-in-next,
|
|
214
|
+
.cui__grid.is-month-in-prev {
|
|
215
|
+
will-change: transform;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.cui--no-animation .cui__grid,
|
|
219
|
+
.cui--no-animation .cui__week {
|
|
220
|
+
transition: none;
|
|
221
|
+
animation: none;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@media (prefers-reduced-motion: reduce) {
|
|
225
|
+
.cui__grid,
|
|
226
|
+
.cui__week {
|
|
227
|
+
transition: none;
|
|
228
|
+
animation: none;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.cui__weekday {
|
|
233
|
+
padding: 4px 0;
|
|
234
|
+
color: var(--cui-muted);
|
|
235
|
+
font-size: 12px;
|
|
236
|
+
text-align: center;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* 日期格 */
|
|
240
|
+
.cui__day {
|
|
241
|
+
position: relative;
|
|
242
|
+
display: flex;
|
|
243
|
+
flex-direction: column;
|
|
244
|
+
align-items: center;
|
|
245
|
+
justify-content: center;
|
|
246
|
+
gap: 2px;
|
|
247
|
+
min-height: 46px;
|
|
248
|
+
padding: 4px 2px;
|
|
249
|
+
border: 1px solid transparent;
|
|
250
|
+
border-radius: 8px;
|
|
251
|
+
background: transparent;
|
|
252
|
+
color: inherit;
|
|
253
|
+
font: inherit;
|
|
254
|
+
cursor: pointer;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.cui__day:hover {
|
|
258
|
+
background: var(--cui-hover);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.cui__day-num {
|
|
262
|
+
font-size: 15px;
|
|
263
|
+
font-weight: 500;
|
|
264
|
+
line-height: 1.1;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/* 周末:日期数字固定用节假日红(--cui-rest),不由节假日数据决定 */
|
|
268
|
+
.cui__day.is-weekend .cui__day-num {
|
|
269
|
+
color: var(--cui-rest);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/* 选中时数字跟随反白色,避免红底红字 */
|
|
273
|
+
.cui__day.is-selected .cui__day-num {
|
|
274
|
+
color: currentColor;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.cui__day-sub {
|
|
278
|
+
max-width: 100%;
|
|
279
|
+
overflow: hidden;
|
|
280
|
+
color: var(--cui-muted);
|
|
281
|
+
font-size: 11px;
|
|
282
|
+
white-space: nowrap;
|
|
283
|
+
text-overflow: ellipsis;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/* 左上角的休 / 班标记 */
|
|
287
|
+
.cui__day-tag {
|
|
288
|
+
position: absolute;
|
|
289
|
+
top: 3px;
|
|
290
|
+
left: 4px;
|
|
291
|
+
font-size: 10px;
|
|
292
|
+
font-weight: 600;
|
|
293
|
+
line-height: 1;
|
|
294
|
+
pointer-events: none;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.cui__day-tag[hidden] {
|
|
298
|
+
display: none;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.cui__day-tag[data-tone="rest"] {
|
|
302
|
+
color: var(--cui-rest);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.cui__day-tag[data-tone="work"] {
|
|
306
|
+
color: var(--cui-accent);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.cui__day.is-selected .cui__day-tag {
|
|
310
|
+
color: currentColor;
|
|
311
|
+
opacity: 0.9;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/* 状态 */
|
|
315
|
+
.cui__day.is-outside {
|
|
316
|
+
opacity: 0.35;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.cui__day.is-disabled,
|
|
320
|
+
.cui__day:disabled {
|
|
321
|
+
opacity: 0.35;
|
|
322
|
+
cursor: not-allowed;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.cui__day.is-disabled:hover,
|
|
326
|
+
.cui__day:disabled:hover {
|
|
327
|
+
background: transparent;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.cui__day[data-tone="rest"] .cui__day-sub {
|
|
331
|
+
color: var(--cui-rest);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.cui__day.is-today {
|
|
335
|
+
border-color: var(--cui-accent);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.cui__day.is-selected {
|
|
339
|
+
background: var(--cui-accent);
|
|
340
|
+
color: var(--cui-accent-fg);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.cui__day.is-in-range:not(.is-selected) {
|
|
344
|
+
background: color-mix(in srgb, var(--cui-accent) 14%, transparent);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.cui__day.is-in-range:hover:not(.is-selected) {
|
|
348
|
+
background: color-mix(in srgb, var(--cui-accent) 22%, transparent);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.cui__day.is-selected .cui__day-sub {
|
|
352
|
+
color: currentColor;
|
|
353
|
+
opacity: 0.85;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/* 折叠开关:始终只有一个按钮,箭头随状态切换 */
|
|
357
|
+
.cui__collapse {
|
|
358
|
+
display: flex;
|
|
359
|
+
width: 100%;
|
|
360
|
+
align-items: center;
|
|
361
|
+
justify-content: center;
|
|
362
|
+
margin-top: 8px;
|
|
363
|
+
padding: 2px 0;
|
|
364
|
+
border: 0;
|
|
365
|
+
border-radius: 6px;
|
|
366
|
+
background: transparent;
|
|
367
|
+
color: var(--cui-muted);
|
|
368
|
+
font: inherit;
|
|
369
|
+
font-size: 14px;
|
|
370
|
+
line-height: 1;
|
|
371
|
+
cursor: pointer;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.cui__collapse:hover {
|
|
375
|
+
color: var(--cui-fg);
|
|
376
|
+
background: var(--cui-hover);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.cui__collapse:focus-visible {
|
|
380
|
+
outline: 2px solid var(--cui-accent);
|
|
381
|
+
outline-offset: 1px;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/* 隐藏状态:类选择器里的 display 会盖掉 [hidden] 的默认样式,这里显式补上 */
|
|
385
|
+
.cui[hidden],
|
|
386
|
+
.cui__header[hidden] {
|
|
387
|
+
display: none;
|
|
388
|
+
}
|