@jsb188/calendar 1.1.10 → 1.1.11
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 +8 -6
- package/src/constants/calendar.ts +8 -1
- package/src/libs/calendar-geometry.ts +167 -91
- package/src/libs/calendar-gesture.ts +58 -15
- package/src/libs/calendar-now.ts +39 -0
- package/src/libs/calendar-range.ts +86 -27
- package/src/libs/calendar-state.ts +10 -3
- package/src/libs/calendar-url.ts +31 -8
- package/src/main.ts +3 -0
- package/src/modules/Calendar.tsx +369 -275
- package/src/modules/MiniCalendar.tsx +370 -0
- package/src/ui/CalendarAgendaUI.tsx +31 -11
- package/src/ui/CalendarCoverageUI.tsx +66 -23
- package/src/ui/CalendarEventDetailUI.tsx +122 -117
- package/src/ui/CalendarEventFormUI.tsx +86 -59
- package/src/ui/CalendarMonthUI.tsx +25 -21
- package/src/ui/CalendarRailUI.tsx +199 -139
- package/src/ui/CalendarRequestUI.tsx +216 -177
- package/src/ui/CalendarToolbarUI.tsx +27 -18
- package/src/ui/CalendarUI.tsx +255 -229
- package/src/ui/CalendarViolationUI.tsx +53 -30
- package/src/ui/CalendarYearUI.tsx +36 -50
- package/tests/calendar-geometry.test.ts +226 -78
- package/tests/calendar-gesture.test.ts +43 -12
- package/tests/calendar-range.test.ts +159 -33
- package/tests/calendar-url.test.ts +55 -12
|
@@ -108,24 +108,34 @@ export const CalendarViolationUI = memo((p: CalendarViolationUIProps) => {
|
|
|
108
108
|
// A clean window is worth stating: an empty strip would read as a
|
|
109
109
|
// surface that failed to load rather than a schedule that is fine
|
|
110
110
|
return (
|
|
111
|
-
<div
|
|
112
|
-
|
|
111
|
+
<div
|
|
112
|
+
className="no_shrink a_c bd_t_1 bd_t_bd"
|
|
113
|
+
style={{ paddingTop: 6, paddingBottom: 6 }}
|
|
114
|
+
>
|
|
115
|
+
<span className="ft_tn cl_lt">{emptyText}</span>
|
|
113
116
|
</div>
|
|
114
117
|
);
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
return (
|
|
118
|
-
<div className=
|
|
121
|
+
<div className="no_shrink v_stretch bd_t_1 bd_t_bd">
|
|
119
122
|
<div
|
|
120
|
-
className=
|
|
121
|
-
style={{
|
|
123
|
+
className="no_shrink h_spread gap_sm"
|
|
124
|
+
style={{
|
|
125
|
+
paddingLeft: 12,
|
|
126
|
+
paddingRight: 12,
|
|
127
|
+
paddingTop: 6,
|
|
128
|
+
paddingBottom: 4,
|
|
129
|
+
}}
|
|
122
130
|
>
|
|
123
|
-
<span className=
|
|
131
|
+
<span className="f ellip ft_tn ft_bold">{summaryText}</span>
|
|
124
132
|
|
|
125
|
-
{blockingHintText ?
|
|
133
|
+
{blockingHintText ? (
|
|
134
|
+
<span className="no_shrink ft_tn cl_err">{blockingHintText}</span>
|
|
135
|
+
) : null}
|
|
126
136
|
</div>
|
|
127
137
|
|
|
128
|
-
<div className=
|
|
138
|
+
<div className="app_scr auto_y" style={{ maxHeight: maxListHeight }}>
|
|
129
139
|
{violations.map((violation) => {
|
|
130
140
|
const isBlock = violation.severity === 'BLOCK';
|
|
131
141
|
const isAcknowledged = !!acknowledgedKeys?.has(violation.key);
|
|
@@ -133,27 +143,35 @@ export const CalendarViolationUI = memo((p: CalendarViolationUIProps) => {
|
|
|
133
143
|
|
|
134
144
|
// The server's wording first, then the caller's per-kind
|
|
135
145
|
// copy, then one generic sentence — never an empty row
|
|
136
|
-
const messageText =
|
|
137
|
-
|
|
138
|
-
||
|
|
146
|
+
const messageText =
|
|
147
|
+
violation.message ||
|
|
148
|
+
fallbackMessageByKind[violation.kind] ||
|
|
149
|
+
fallbackMessageText;
|
|
139
150
|
|
|
140
151
|
return (
|
|
141
152
|
<div
|
|
142
153
|
key={violation.key}
|
|
143
154
|
className={cn(
|
|
144
155
|
'h_item gap_sm bd_l_4',
|
|
145
|
-
isBlock
|
|
156
|
+
isBlock
|
|
157
|
+
? 'bg_red_alt_lt bd_red_md'
|
|
158
|
+
: 'bg_amber_alt_lt bd_amber_md',
|
|
146
159
|
selectedKey === violation.key ? 'ol_primary' : '',
|
|
147
160
|
)}
|
|
148
161
|
style={{ paddingRight: 12, marginBottom: 1 }}
|
|
149
162
|
>
|
|
150
163
|
<button
|
|
151
|
-
type=
|
|
152
|
-
className=
|
|
164
|
+
type="button"
|
|
165
|
+
className="f a_l h_item gap_sm"
|
|
153
166
|
style={{ paddingLeft: 8, paddingTop: 5, paddingBottom: 5 }}
|
|
154
167
|
onClick={onSelect ? () => onSelect(violation.key) : undefined}
|
|
155
168
|
>
|
|
156
|
-
<span
|
|
169
|
+
<span
|
|
170
|
+
className={cn(
|
|
171
|
+
'no_shrink h_center',
|
|
172
|
+
isBlock ? 'cl_err' : 'cl_warn',
|
|
173
|
+
)}
|
|
174
|
+
>
|
|
157
175
|
<Icon
|
|
158
176
|
name={isBlock ? 'alert-circle-filled' : 'alert-circle'}
|
|
159
177
|
height={15}
|
|
@@ -161,7 +179,7 @@ export const CalendarViolationUI = memo((p: CalendarViolationUIProps) => {
|
|
|
161
179
|
/>
|
|
162
180
|
</span>
|
|
163
181
|
|
|
164
|
-
<span className=
|
|
182
|
+
<span className="f v_stretch of">
|
|
165
183
|
<span
|
|
166
184
|
className={cn(
|
|
167
185
|
'ellip ft_tn',
|
|
@@ -173,31 +191,36 @@ export const CalendarViolationUI = memo((p: CalendarViolationUIProps) => {
|
|
|
173
191
|
{messageText}
|
|
174
192
|
</span>
|
|
175
193
|
|
|
176
|
-
<span className=
|
|
194
|
+
<span className="ellip ft_tn cl_lt">
|
|
177
195
|
{timeRangeByKey.get(violation.key) || ''}
|
|
178
196
|
{contextText ? <span> · {contextText}</span> : null}
|
|
179
197
|
</span>
|
|
180
198
|
</span>
|
|
181
199
|
|
|
182
|
-
<span
|
|
200
|
+
<span
|
|
201
|
+
className={cn(
|
|
202
|
+
'no_shrink ft_tn ft_bold',
|
|
203
|
+
isBlock ? 'cl_err' : 'cl_warn',
|
|
204
|
+
)}
|
|
205
|
+
>
|
|
183
206
|
{isBlock ? blockText : warnText}
|
|
184
207
|
</span>
|
|
185
208
|
</button>
|
|
186
209
|
|
|
187
210
|
{/* A BLOCK is never acknowledgeable — the whole point of the
|
|
188
211
|
severity is that no amount of agreeing lets it publish */}
|
|
189
|
-
{!isBlock && onAcknowledge
|
|
190
|
-
|
|
191
|
-
<
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
</
|
|
199
|
-
|
|
200
|
-
|
|
212
|
+
{!isBlock && onAcknowledge ? (
|
|
213
|
+
<label className="no_shrink h_item gap_sm pointer unsel">
|
|
214
|
+
<ToggleSwitch
|
|
215
|
+
size="xs"
|
|
216
|
+
checked={isAcknowledged}
|
|
217
|
+
onChange={(event) =>
|
|
218
|
+
onAcknowledge(violation.key, event.currentTarget.checked)
|
|
219
|
+
}
|
|
220
|
+
/>
|
|
221
|
+
<span className="ft_tn cl_md">{acknowledgeText}</span>
|
|
222
|
+
</label>
|
|
223
|
+
) : null}
|
|
201
224
|
</div>
|
|
202
225
|
);
|
|
203
226
|
})}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import { cn } from '@jsb188/app/utils/string.ts';
|
|
2
1
|
import { memo } from 'react';
|
|
3
|
-
import
|
|
2
|
+
import { MiniCalendar } from '../modules/MiniCalendar.tsx';
|
|
3
|
+
|
|
4
|
+
const FILE_CONSTANTS = {
|
|
5
|
+
gridStyle: {
|
|
6
|
+
display: 'grid' as const,
|
|
7
|
+
// Three across on a laptop, collapsing to one on a phone,
|
|
8
|
+
// without a media query or a new class
|
|
9
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))',
|
|
10
|
+
gap: 16,
|
|
11
|
+
padding: 16,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
4
14
|
|
|
5
15
|
/**
|
|
6
16
|
* The year view: twelve mini month grids.
|
|
@@ -10,70 +20,46 @@ import type { CalendarDayObj } from '../types/calendar.d.ts';
|
|
|
10
20
|
* and a grid built from a truncated list would quietly show empty days that
|
|
11
21
|
* are not empty. Clicking a day jumps into it, which is what a year view is
|
|
12
22
|
* actually for.
|
|
23
|
+
*
|
|
24
|
+
* Each month is a <MiniCalendar>, which draws its own grid from a single date.
|
|
25
|
+
* That is the same component the calendar page's sidebar uses, so the two can
|
|
26
|
+
* never drift apart on which day a month starts under.
|
|
13
27
|
*/
|
|
14
28
|
|
|
15
29
|
export interface CalendarYearMonthObj {
|
|
16
30
|
// Localized month name
|
|
17
31
|
label: string;
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
days: CalendarDayObj[];
|
|
21
|
-
dayNumberLabels: string[];
|
|
32
|
+
// Any instant inside the month; the mini grid derives the rest
|
|
33
|
+
monthDate: Date;
|
|
22
34
|
}
|
|
23
35
|
|
|
24
36
|
export interface CalendarYearUIProps {
|
|
25
37
|
months: CalendarYearMonthObj[];
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
timeZone?: string | null;
|
|
39
|
+
locale?: string | null;
|
|
40
|
+
weekStartsOn?: number;
|
|
41
|
+
todayDateKey?: string | null;
|
|
28
42
|
onSelectDay: (dateKey: string) => void;
|
|
29
43
|
}
|
|
30
44
|
|
|
31
45
|
export const CalendarYearUI = memo((p: CalendarYearUIProps) => {
|
|
32
|
-
const { months,
|
|
46
|
+
const { months, timeZone, locale, weekStartsOn, todayDateKey, onSelectDay } =
|
|
47
|
+
p;
|
|
33
48
|
|
|
34
49
|
return (
|
|
35
|
-
<div className=
|
|
36
|
-
<div
|
|
37
|
-
style={{
|
|
38
|
-
display: 'grid',
|
|
39
|
-
// Three across on a laptop, collapsing to one on a phone,
|
|
40
|
-
// without a media query or a new class
|
|
41
|
-
gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))',
|
|
42
|
-
gap: 16,
|
|
43
|
-
padding: 16,
|
|
44
|
-
}}
|
|
45
|
-
>
|
|
50
|
+
<div className="f h_0 app_scr auto_y">
|
|
51
|
+
<div style={FILE_CONSTANTS.gridStyle}>
|
|
46
52
|
{months.map((month) => (
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
))}
|
|
58
|
-
|
|
59
|
-
{Array.from({ length: month.leadingBlankCount }, (_unused, index) => <div key={`blank${index}`} />)}
|
|
60
|
-
|
|
61
|
-
{month.days.map((day, index) => (
|
|
62
|
-
<button
|
|
63
|
-
key={day.dateKey}
|
|
64
|
-
type='button'
|
|
65
|
-
className={cn(
|
|
66
|
-
'a_c ft_tn r_xs',
|
|
67
|
-
day.isToday ? 'ft_bold bg_active' : 'cl_md',
|
|
68
|
-
)}
|
|
69
|
-
style={{ paddingTop: 2, paddingBottom: 2 }}
|
|
70
|
-
onClick={() => onSelectDay(day.dateKey)}
|
|
71
|
-
>
|
|
72
|
-
{month.dayNumberLabels[index]}
|
|
73
|
-
</button>
|
|
74
|
-
))}
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
53
|
+
<MiniCalendar
|
|
54
|
+
key={month.label}
|
|
55
|
+
title={month.label}
|
|
56
|
+
monthDate={month.monthDate}
|
|
57
|
+
timeZone={timeZone}
|
|
58
|
+
locale={locale}
|
|
59
|
+
weekStartsOn={weekStartsOn}
|
|
60
|
+
todayDateKey={todayDateKey}
|
|
61
|
+
onSelectDay={onSelectDay}
|
|
62
|
+
/>
|
|
77
63
|
))}
|
|
78
64
|
</div>
|
|
79
65
|
</div>
|