@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.
@@ -65,115 +65,167 @@ export interface CalendarRailUIProps {
65
65
  * The rail's mini month grid.
66
66
  */
67
67
 
68
- const CalendarRailMiniMonthUI = memo((p: {
69
- miniMonth: CalendarRailMiniMonthObj;
70
- weekdayInitials: string[];
71
- selectedDateKey?: string | null;
72
- previousMonthText: string;
73
- nextMonthText: string;
74
- onSelectDay: (dateKey: string) => void;
75
- onStepMonth: (direction: 1 | -1) => void;
76
- }) => {
77
- const { miniMonth, weekdayInitials, selectedDateKey, previousMonthText, nextMonthText, onSelectDay, onStepMonth } = p;
68
+ const CalendarRailMiniMonthUI = memo(
69
+ (p: {
70
+ miniMonth: CalendarRailMiniMonthObj;
71
+ weekdayInitials: string[];
72
+ selectedDateKey?: string | null;
73
+ previousMonthText: string;
74
+ nextMonthText: string;
75
+ onSelectDay: (dateKey: string) => void;
76
+ onStepMonth: (direction: 1 | -1) => void;
77
+ }) => {
78
+ const {
79
+ miniMonth,
80
+ weekdayInitials,
81
+ selectedDateKey,
82
+ previousMonthText,
83
+ nextMonthText,
84
+ onSelectDay,
85
+ onStepMonth,
86
+ } = p;
78
87
 
79
- return (
80
- <div className='no_shrink' style={{ paddingLeft: 12, paddingRight: 12, paddingTop: 8, paddingBottom: 8 }}>
81
- <div className='h_item gap_sm'>
82
- <span className='f ellip ft_sm ft_bold cl_md'>{miniMonth.label}</span>
88
+ return (
89
+ <div
90
+ className="no_shrink"
91
+ style={{
92
+ paddingLeft: 12,
93
+ paddingRight: 12,
94
+ paddingTop: 8,
95
+ paddingBottom: 8,
96
+ }}
97
+ >
98
+ <div className="h_item gap_sm">
99
+ <span className="f ellip ft_sm ft_bold cl_md">{miniMonth.label}</span>
83
100
 
84
- {/* No IconButton exists in the kit, so these are the documented raw
101
+ {/* No IconButton exists in the kit, so these are the documented raw
85
102
  pattern: a bare button wrapping an Icon */}
86
- <button
87
- type='button'
88
- className='no_shrink av_sm h_center'
89
- aria-label={previousMonthText}
90
- title={previousMonthText}
91
- onClick={() => onStepMonth(-1)}
92
- >
93
- <Icon name='arrow-left' />
94
- </button>
95
-
96
- <button
97
- type='button'
98
- className='no_shrink av_sm h_center'
99
- aria-label={nextMonthText}
100
- title={nextMonthText}
101
- onClick={() => onStepMonth(1)}
102
- >
103
- <Icon name='arrow-right' />
104
- </button>
105
- </div>
106
-
107
- <div style={{ display: 'grid', gridTemplateColumns: 'repeat(7, minmax(0, 1fr))' }}>
108
- {weekdayInitials.map((initial, index) => (
109
- <div key={index} className='a_c ft_tn cl_lt'>
110
- {initial}
111
- </div>
112
- ))}
113
-
114
- {Array.from({ length: miniMonth.leadingBlankCount }, (_unused, index) => <div key={`blank${index}`} />)}
103
+ <button
104
+ type="button"
105
+ className="no_shrink av_sm h_center"
106
+ aria-label={previousMonthText}
107
+ title={previousMonthText}
108
+ onClick={() => onStepMonth(-1)}
109
+ >
110
+ <Icon name="arrow-left" />
111
+ </button>
115
112
 
116
- {miniMonth.days.map((day, index) => (
117
113
  <button
118
- key={day.dateKey}
119
- type='button'
120
- className={cn(
121
- 'a_c ft_tn r_xs',
122
- // Today is bold and the anchored day is filled, so the two
123
- // stay tellable apart when they are not the same day; a
124
- // day borrowed from the next month recedes rather than
125
- // disappearing
126
- day.isToday ? 'ft_bold' : day.isInPrimaryRange ? 'cl_md' : 'cl_lt',
127
- day.dateKey === selectedDateKey ? 'bg_active' : '',
128
- )}
129
- style={{ paddingTop: 2, paddingBottom: 2 }}
130
- onClick={() => onSelectDay(day.dateKey)}
131
- aria-current={day.dateKey === selectedDateKey ? 'date' : undefined}
114
+ type="button"
115
+ className="no_shrink av_sm h_center"
116
+ aria-label={nextMonthText}
117
+ title={nextMonthText}
118
+ onClick={() => onStepMonth(1)}
132
119
  >
133
- {miniMonth.dayNumberLabels[index]}
120
+ <Icon name="arrow-right" />
134
121
  </button>
135
- ))}
122
+ </div>
123
+
124
+ <div
125
+ style={{
126
+ display: 'grid',
127
+ gridTemplateColumns: 'repeat(7, minmax(0, 1fr))',
128
+ }}
129
+ >
130
+ {weekdayInitials.map((initial, index) => (
131
+ <div key={index} className="a_c ft_tn cl_lt">
132
+ {initial}
133
+ </div>
134
+ ))}
135
+
136
+ {Array.from(
137
+ { length: miniMonth.leadingBlankCount },
138
+ (_unused, index) => (
139
+ <div key={`blank${index}`} />
140
+ ),
141
+ )}
142
+
143
+ {miniMonth.days.map((day, index) => (
144
+ <button
145
+ key={day.dateKey}
146
+ type="button"
147
+ className={cn(
148
+ 'a_c ft_tn r_xs',
149
+ // Today is bold and the anchored day is filled, so the two
150
+ // stay tellable apart when they are not the same day; a
151
+ // day borrowed from the next month recedes rather than
152
+ // disappearing
153
+ day.isToday
154
+ ? 'ft_bold'
155
+ : day.isInPrimaryRange
156
+ ? 'cl_md'
157
+ : 'cl_lt',
158
+ day.dateKey === selectedDateKey ? 'bg_active' : '',
159
+ )}
160
+ style={{ paddingTop: 2, paddingBottom: 2 }}
161
+ onClick={() => onSelectDay(day.dateKey)}
162
+ aria-current={
163
+ day.dateKey === selectedDateKey ? 'date' : undefined
164
+ }
165
+ >
166
+ {miniMonth.dayNumberLabels[index]}
167
+ </button>
168
+ ))}
169
+ </div>
136
170
  </div>
137
- </div>
138
- );
139
- });
171
+ );
172
+ },
173
+ );
140
174
 
141
175
  /**
142
176
  * One calendar's row: its colour, its name, and whether it is drawn.
143
177
  */
144
178
 
145
- const CalendarRailSourceUI = memo((p: {
146
- calendar: CalendarSourceObj;
147
- onToggleCalendar: (calendarId: string, nextVisible: boolean) => void;
148
- }) => {
149
- const { calendar, onToggleCalendar } = p;
179
+ const CalendarRailSourceUI = memo(
180
+ (p: {
181
+ calendar: CalendarSourceObj;
182
+ onToggleCalendar: (calendarId: string, nextVisible: boolean) => void;
183
+ }) => {
184
+ const { calendar, onToggleCalendar } = p;
150
185
 
151
- return (
152
- <label
153
- className='h_item gap_sm pointer unsel'
154
- style={{ paddingLeft: 12, paddingRight: 12, paddingTop: 4, paddingBottom: 4 }}
155
- >
156
- {/* The swatch is DATA — it is the calendar's own colour — so it is an
186
+ return (
187
+ <label
188
+ className="h_item gap_sm pointer unsel"
189
+ style={{
190
+ paddingLeft: 12,
191
+ paddingRight: 12,
192
+ paddingTop: 4,
193
+ paddingBottom: 4,
194
+ }}
195
+ >
196
+ {/* The swatch is DATA — it is the calendar's own colour — so it is an
157
197
  inline background rather than a class. A calendar with no colour
158
198
  set gets the neutral chip instead of a black dot. */}
159
- <span
160
- className={cn('no_shrink r_xs bd_1 bd_bd', calendar.color ? '' : 'bg_alt')}
161
- style={{ width: 10, height: 10, backgroundColor: calendar.color || undefined }}
162
- />
199
+ <span
200
+ className={cn(
201
+ 'no_shrink r_xs bd_1 bd_bd',
202
+ calendar.color ? '' : 'bg_alt',
203
+ )}
204
+ style={{
205
+ width: 10,
206
+ height: 10,
207
+ backgroundColor: calendar.color || undefined,
208
+ }}
209
+ />
163
210
 
164
- <span className='f ellip ft_sm' title={calendar.name}>{calendar.name}</span>
211
+ <span className="f ellip ft_sm" title={calendar.name}>
212
+ {calendar.name}
213
+ </span>
165
214
 
166
- {/* Visibility is a viewer's own concern, so even a calendar they
215
+ {/* Visibility is a viewer's own concern, so even a calendar they
167
216
  cannot edit can be hidden */}
168
- <ToggleSwitch
169
- size='sm'
170
- className='no_shrink'
171
- checked={calendar.visible}
172
- onChange={(event) => onToggleCalendar(calendar.id, event.currentTarget.checked)}
173
- />
174
- </label>
175
- );
176
- });
217
+ <ToggleSwitch
218
+ size="sm"
219
+ className="no_shrink"
220
+ checked={calendar.visible}
221
+ onChange={(event) =>
222
+ onToggleCalendar(calendar.id, event.currentTarget.checked)
223
+ }
224
+ />
225
+ </label>
226
+ );
227
+ },
228
+ );
177
229
 
178
230
  export const CalendarRailUI = memo((p: CalendarRailUIProps) => {
179
231
  const {
@@ -203,80 +255,88 @@ export const CalendarRailUI = memo((p: CalendarRailUIProps) => {
203
255
  }
204
256
 
205
257
  return (
206
- <div className='no_shrink v_stretch h_f bd_r_1 bd_r_bd bg' style={{ width: 36, paddingTop: 6 }}>
258
+ <div
259
+ className="no_shrink v_stretch h_f bd_r_1 bd_r_bd bg"
260
+ style={{ width: 36, paddingTop: 6 }}
261
+ >
207
262
  <button
208
- type='button'
209
- className='av_sm h_center'
263
+ type="button"
264
+ className="av_sm h_center"
210
265
  aria-label={expandText}
211
266
  title={expandText}
212
267
  onClick={() => onToggleOpen(true)}
213
268
  >
214
- <Icon name='sidebar-expand' />
269
+ <Icon name="sidebar-expand" />
215
270
  </button>
216
271
  </div>
217
272
  );
218
273
  }
219
274
 
220
275
  return (
221
- <div className='no_shrink v_stretch h_f bd_r_1 bd_r_bd bg' style={{ width: 232 }}>
222
- {miniMonth
223
- ? (
224
- <CalendarRailMiniMonthUI
225
- miniMonth={miniMonth}
226
- weekdayInitials={weekdayInitials}
227
- selectedDateKey={selectedDateKey}
228
- previousMonthText={previousMonthText}
229
- nextMonthText={nextMonthText}
230
- onSelectDay={onSelectDay}
231
- onStepMonth={onStepMonth}
232
- />
233
- )
234
- : null}
276
+ <div
277
+ className="no_shrink v_stretch h_f bd_r_1 bd_r_bd bg"
278
+ style={{ width: 232 }}
279
+ >
280
+ {miniMonth ? (
281
+ <CalendarRailMiniMonthUI
282
+ miniMonth={miniMonth}
283
+ weekdayInitials={weekdayInitials}
284
+ selectedDateKey={selectedDateKey}
285
+ previousMonthText={previousMonthText}
286
+ nextMonthText={nextMonthText}
287
+ onSelectDay={onSelectDay}
288
+ onStepMonth={onStepMonth}
289
+ />
290
+ ) : null}
235
291
 
236
292
  <div
237
- className='no_shrink h_item gap_sm bd_t_1 bd_t_bd'
238
- style={{ paddingLeft: 12, paddingRight: 6, paddingTop: 6, paddingBottom: 2 }}
293
+ className="no_shrink h_item gap_sm bd_t_1 bd_t_bd"
294
+ style={{
295
+ paddingLeft: 12,
296
+ paddingRight: 6,
297
+ paddingTop: 6,
298
+ paddingBottom: 2,
299
+ }}
239
300
  >
240
- <span className='f ellip ft_tn cl_lt'>{calendarsText}</span>
301
+ <span className="f ellip ft_tn cl_lt">{calendarsText}</span>
241
302
 
242
- {onToggleOpen
243
- ? (
244
- <button
245
- type='button'
246
- className='no_shrink av_sm h_center'
247
- aria-label={collapseText}
248
- title={collapseText}
249
- onClick={() => onToggleOpen(false)}
250
- >
251
- <Icon name='sidebar-close' />
252
- </button>
253
- )
254
- : null}
303
+ {onToggleOpen ? (
304
+ <button
305
+ type="button"
306
+ className="no_shrink av_sm h_center"
307
+ aria-label={collapseText}
308
+ title={collapseText}
309
+ onClick={() => onToggleOpen(false)}
310
+ >
311
+ <Icon name="sidebar-close" />
312
+ </button>
313
+ ) : null}
255
314
  </div>
256
315
 
257
- <div className='f h_0 app_scr auto_y'>
258
- {calendars.length
259
- ? calendars.map((calendar) => (
316
+ <div className="f h_0 app_scr auto_y">
317
+ {calendars.length ? (
318
+ calendars.map((calendar) => (
260
319
  <CalendarRailSourceUI
261
320
  key={calendar.id}
262
321
  calendar={calendar}
263
322
  onToggleCalendar={onToggleCalendar}
264
323
  />
265
324
  ))
266
- : (
267
- <div className='ft_tn cl_lt' style={{ paddingLeft: 12, paddingRight: 12, paddingTop: 4 }}>
268
- {emptyText}
269
- </div>
270
- )}
325
+ ) : (
326
+ <div
327
+ className="ft_tn cl_lt"
328
+ style={{ paddingLeft: 12, paddingRight: 12, paddingTop: 4 }}
329
+ >
330
+ {emptyText}
331
+ </div>
332
+ )}
271
333
  </div>
272
334
 
273
- {FooterComponent
274
- ? (
275
- <div className='no_shrink bd_t_1 bd_t_bd' style={{ padding: 8 }}>
276
- {FooterComponent}
277
- </div>
278
- )
279
- : null}
335
+ {FooterComponent ? (
336
+ <div className="no_shrink bd_t_1 bd_t_bd" style={{ padding: 8 }}>
337
+ {FooterComponent}
338
+ </div>
339
+ ) : null}
280
340
  </div>
281
341
  );
282
342
  });