@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.
@@ -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 className='no_shrink a_c bd_t_1 bd_t_bd' style={{ paddingTop: 6, paddingBottom: 6 }}>
112
- <span className='ft_tn cl_lt'>{emptyText}</span>
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='no_shrink v_stretch bd_t_1 bd_t_bd'>
121
+ <div className="no_shrink v_stretch bd_t_1 bd_t_bd">
119
122
  <div
120
- className='no_shrink h_spread gap_sm'
121
- style={{ paddingLeft: 12, paddingRight: 12, paddingTop: 6, paddingBottom: 4 }}
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='f ellip ft_tn ft_bold'>{summaryText}</span>
131
+ <span className="f ellip ft_tn ft_bold">{summaryText}</span>
124
132
 
125
- {blockingHintText ? <span className='no_shrink ft_tn cl_err'>{blockingHintText}</span> : null}
133
+ {blockingHintText ? (
134
+ <span className="no_shrink ft_tn cl_err">{blockingHintText}</span>
135
+ ) : null}
126
136
  </div>
127
137
 
128
- <div className='app_scr auto_y' style={{ maxHeight: maxListHeight }}>
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 = violation.message
137
- || fallbackMessageByKind[violation.kind]
138
- || fallbackMessageText;
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 ? 'bg_red_alt_lt bd_red_md' : 'bg_amber_alt_lt bd_amber_md',
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='button'
152
- className='f a_l h_item gap_sm'
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 className={cn('no_shrink h_center', isBlock ? 'cl_err' : 'cl_warn')}>
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='f v_stretch of'>
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='ellip ft_tn cl_lt'>
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 className={cn('no_shrink ft_tn ft_bold', isBlock ? 'cl_err' : 'cl_warn')}>
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
- <label className='no_shrink h_item gap_sm pointer unsel'>
192
- <ToggleSwitch
193
- size='xs'
194
- checked={isAcknowledged}
195
- onChange={(event) => onAcknowledge(violation.key, event.currentTarget.checked)}
196
- />
197
- <span className='ft_tn cl_md'>{acknowledgeText}</span>
198
- </label>
199
- )
200
- : null}
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 type { CalendarDayObj } from '../types/calendar.d.ts';
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
- // Leading blanks before the first day, so the 1st lands under its weekday
19
- leadingBlankCount: number;
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
- // Single-letter weekday initials for each mini grid's header
27
- weekdayInitials: string[];
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, weekdayInitials, onSelectDay } = p;
46
+ const { months, timeZone, locale, weekStartsOn, todayDateKey, onSelectDay } =
47
+ p;
33
48
 
34
49
  return (
35
- <div className='f h_0 app_scr auto_y'>
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
- <div key={month.label}>
48
- <div className='ft_sm ft_bold cl_md' style={{ marginBottom: 4 }}>
49
- {month.label}
50
- </div>
51
-
52
- <div style={{ display: 'grid', gridTemplateColumns: 'repeat(7, minmax(0, 1fr))' }}>
53
- {weekdayInitials.map((initial, index) => (
54
- <div key={index} className='a_c ft_tn cl_lt'>
55
- {initial}
56
- </div>
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>