@typescript-calendar-lib/react 0.5.2 → 0.5.4
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 +106 -5
- package/dist/calendar.css +77 -8
- package/dist/index.d.ts +20 -8
- package/dist/index.js +77 -59
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -36,6 +36,43 @@ export function App() {
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
## Server-side rendering
|
|
40
|
+
|
|
41
|
+
`Calendar` and `InteractiveCalendar` do not access browser APIs while rendering, so they can be rendered on the server:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { renderToString } from "react-dom/server";
|
|
45
|
+
import { Calendar } from "@typescript-calendar-lib/react";
|
|
46
|
+
|
|
47
|
+
const html = renderToString(
|
|
48
|
+
<Calendar year={2026} month={9} today={new Date(2026, 8, 15)} />,
|
|
49
|
+
);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
In the Next.js App Router, a Server Component renders the calendar on the server by default:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
// app/page.tsx
|
|
56
|
+
import { Calendar } from "@typescript-calendar-lib/react";
|
|
57
|
+
|
|
58
|
+
export default function Page() {
|
|
59
|
+
return <Calendar year={2026} month={9} />;
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Use a Client Component when the calendar needs browser interaction:
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
// app/calendar-panel.tsx
|
|
67
|
+
"use client";
|
|
68
|
+
|
|
69
|
+
import { InteractiveCalendar } from "@typescript-calendar-lib/react";
|
|
70
|
+
|
|
71
|
+
export function CalendarPanel() {
|
|
72
|
+
return <InteractiveCalendar initialYear={2026} initialMonth={9} />;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
39
76
|
## Component API
|
|
40
77
|
|
|
41
78
|
### `Calendar`
|
|
@@ -49,22 +86,25 @@ export function App() {
|
|
|
49
86
|
| `year` | `number` | — (required) | Calendar year |
|
|
50
87
|
| `month` | `number` | — (required) | Month, 1-indexed (`1`–`12`) |
|
|
51
88
|
| `locale` | `"en" \| "ja" \| "es" \| "de" \| "fr" \| "ko" \| "zh"` | `"en"` | Language |
|
|
89
|
+
| `holidayLocale` | `"en" \| "ja" \| "es" \| "de" \| "fr" \| "ko" \| "zh"` | `"ja"` | Holiday rules; currently only `"ja"` is provided |
|
|
52
90
|
| `weekStart` | `"sunday" \| "monday"` | `"sunday"` | First day of the week |
|
|
53
91
|
| `highlight` | `Date` | — | Date to highlight |
|
|
54
92
|
| `range` | `{ from: Date; to: Date }` | — | Dates to emphasize |
|
|
55
93
|
| `rangePreview` | `{ from: Date; to: Date }` | — | Candidate range preview (hover preview), rendered with the `is-in-range-preview` class |
|
|
94
|
+
| `isDateDisabled` | `(date: Date) => boolean` | — | Mark dates as non-selectable in interactive mode (`is-disabled` class) |
|
|
56
95
|
| `today` | `Date` | — | Reference date for "today" styling |
|
|
57
96
|
| `theme` | `ThemeName \| ReactTheme` | `"default"` | CSS class-based theme |
|
|
58
97
|
| `colorScheme` | `ColorSchemeName \| ReactColorScheme` | `"default"` | CSS variable-based colors |
|
|
59
98
|
| `size` | `CalendarSize` | `"md"` | Cell size |
|
|
60
99
|
| `responsive` | `boolean` | `false` | Shrink cells & padding below `480px` so the grid fits phone screens |
|
|
100
|
+
| `showWeekNumbers` | `boolean` | `false` | Render a leading week-number column (`th[scope="row"]` with class `calendar-week`); the number follows `weekStart` (`"monday"` → ISO week, `"sunday"` → week-containing-Jan-1 week) |
|
|
61
101
|
| `style` | `CSSProperties` | — | Extra styles for the root element |
|
|
62
102
|
| `interactive` | `boolean` | `false` | Enable cell click/hover/keyboard selection |
|
|
63
103
|
| `onDateClick` | `(date: Date, data?: unknown) => void` | — | Called when a day cell is clicked (or Enter/Space pressed); `data` is that cell's `cellData` value (`undefined` when none) |
|
|
64
104
|
| `onDateHover` | `(date: Date) => void` | — | Called when a day cell is hovered |
|
|
65
105
|
| `onDateLeave` | `() => void` | — | Called when the mouse leaves the calendar |
|
|
66
106
|
| `onKeyDown` | `(e: KeyboardEvent) => void` | — | Keyboard handler on the grid element |
|
|
67
|
-
| `selectedDate` | `Date \| null` | `null` | Marks the
|
|
107
|
+
| `selectedDate` | `Date \| null` | `null` | Marks the gridcell `aria-selected` and its interactive button `aria-pressed` |
|
|
68
108
|
| `cursorDate` | `Date \| null` | `null` | The cell that gets `tabIndex=0` (roving tabindex) |
|
|
69
109
|
| `hoveredDate` | `Date \| null` | `null` | Marks the hovered cell with the `is-hovered` class |
|
|
70
110
|
| `cellData` | `(date: Date) => unknown` | — | Resolve per-cell data; passed to `renderCell` and `onDateClick` |
|
|
@@ -109,9 +149,11 @@ function App() {
|
|
|
109
149
|
selectDate, // () => void — select date under cursor
|
|
110
150
|
setCursorToDate, // (date) => void — move cursor to a date (same month only)
|
|
111
151
|
selectDateAt, // (date) => void — move cursor to a date and select it
|
|
152
|
+
selectRange, // (from, to) => void — set a committed range (range mode)
|
|
112
153
|
clearSelection,
|
|
113
154
|
cursorDate, // Date | null
|
|
114
155
|
selectedDate, // Date | null
|
|
156
|
+
selectedRange, // DateRange | null — committed range (range mode)
|
|
115
157
|
hoveredDate, // Date | null
|
|
116
158
|
setHoveredDate, // (date | null) => void
|
|
117
159
|
} = useCalendarState({
|
|
@@ -135,7 +177,7 @@ function App() {
|
|
|
135
177
|
}
|
|
136
178
|
```
|
|
137
179
|
|
|
138
|
-
`options` also accepts `onMonthChange: (year, month) => void`, called whenever the displayed month changes.
|
|
180
|
+
`options` also accepts `holidayLocale`, `isDateDisabled`, `selectionMode: "single" | "range"` (default `"single"`) and `onMonthChange: (year, month) => void`, called whenever the displayed month changes.
|
|
139
181
|
|
|
140
182
|
## InteractiveCalendar
|
|
141
183
|
|
|
@@ -147,6 +189,7 @@ function App() {
|
|
|
147
189
|
| Hover a cell | Tracks the hovered date (adds `is-hovered` class); fires `onDateHover` |
|
|
148
190
|
| Mouse leaves | Clears the hover state; fires `onDateLeave` |
|
|
149
191
|
| Selection + hover | Shows a range preview between the selected date and the hovered date (`is-in-range-preview` class) |
|
|
192
|
+
| Picking (range mode) | Alternates anchor → committed range → new anchor (`selectionMode="range"`) |
|
|
150
193
|
| Arrow keys | Move the cursor (focus follows the cursor cell) |
|
|
151
194
|
| `PageUp` / `PageDown` | Previous / next month |
|
|
152
195
|
| Enter / Space | Same as clicking the focused cell (selects it) |
|
|
@@ -170,7 +213,41 @@ function App() {
|
|
|
170
213
|
}
|
|
171
214
|
```
|
|
172
215
|
|
|
173
|
-
It accepts the `useCalendarState` options (`initialYear`, `initialMonth`, `locale`, `weekStart`, `highlight`, `range`, `today`, `onMonthChange`) plus the `Calendar` visual props (`theme`, `colorScheme`, `size`, `responsive`, `style`, `cellData`, `renderCell`) and event callbacks (`onDateClick`, `onDateHover`, `onDateLeave`).
|
|
216
|
+
It accepts the `useCalendarState` options (`initialYear`, `initialMonth`, `locale`, `holidayLocale`, `weekStart`, `selectionMode`, `highlight`, `range`, `today`, `isDateDisabled`, `onMonthChange`) plus the `Calendar` visual props (`theme`, `colorScheme`, `size`, `responsive`, `style`, `cellData`, `renderCell`) and event callbacks (`onDateClick`, `onDateHover`, `onDateLeave`).
|
|
217
|
+
|
|
218
|
+
### Disabled Dates
|
|
219
|
+
|
|
220
|
+
Pass `isDateDisabled` to mark dates as non-selectable. Disabled cells get the `is-disabled` class, cannot receive keyboard focus or be clicked, and `Arrow*` navigation skips over them:
|
|
221
|
+
|
|
222
|
+
```tsx
|
|
223
|
+
<InteractiveCalendar
|
|
224
|
+
initialYear={2026}
|
|
225
|
+
initialMonth={9}
|
|
226
|
+
isDateDisabled={(date) => date.getDay() === 0} // disable Sundays
|
|
227
|
+
/>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Range selection
|
|
231
|
+
|
|
232
|
+
Pass `selectionMode="range"` to select a date range by clicking. Selection alternates between **anchor → range → reset**: the 1st click sets an anchor, the 2nd commits the range, and the 3rd starts a new anchor. The committed range is kept as the preview until the next pick begins.
|
|
233
|
+
|
|
234
|
+
```tsx
|
|
235
|
+
<InteractiveCalendar
|
|
236
|
+
initialYear={2026}
|
|
237
|
+
initialMonth={9}
|
|
238
|
+
selectionMode="range"
|
|
239
|
+
/>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
With the raw hook, use `selectRange(from, to)` to set the range explicitly and read it back from the `selectedRange` return value:
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
const { state, selectRange, selectedRange } = useCalendarState({
|
|
246
|
+
initialYear: 2026,
|
|
247
|
+
initialMonth: 9,
|
|
248
|
+
selectionMode: "range",
|
|
249
|
+
});
|
|
250
|
+
```
|
|
174
251
|
|
|
175
252
|
## Custom Cell Rendering
|
|
176
253
|
|
|
@@ -272,6 +349,7 @@ Available variables:
|
|
|
272
349
|
| `--cal-fg` | Foreground |
|
|
273
350
|
| `--cal-accent` | Accent (highlight) |
|
|
274
351
|
| `--cal-weekend-fg` | Weekend foreground |
|
|
352
|
+
| `--cal-holiday-fg` | Holiday foreground |
|
|
275
353
|
| `--cal-border` | Borders |
|
|
276
354
|
| `--cal-header-bg` | Header background |
|
|
277
355
|
| `--cal-highlight-bg` | Highlight background |
|
|
@@ -280,6 +358,11 @@ Available variables:
|
|
|
280
358
|
| `--cal-range-preview-bg` | Range preview background (falls back to `--cal-range-bg`) |
|
|
281
359
|
| `--cal-today-bg` | Today background |
|
|
282
360
|
| `--cal-today-fg` | Today foreground |
|
|
361
|
+
| `--cal-selected-bg` | Selected cell background (interactive mode) |
|
|
362
|
+
| `--cal-selected-fg` | Selected cell foreground (interactive mode) |
|
|
363
|
+
| `--cal-disabled-fg` | Disabled cell foreground |
|
|
364
|
+
|
|
365
|
+
`calendar.css` also uses a CSS-only `--cal-hover-bg` (falls back to `--cal-range-bg`) for the interactive hover state; set it with `style` or your own CSS.
|
|
283
366
|
|
|
284
367
|
Pass a custom scheme directly:
|
|
285
368
|
|
|
@@ -349,18 +432,29 @@ The `style` prop can override any CSS variable or add custom styles:
|
|
|
349
432
|
/>
|
|
350
433
|
```
|
|
351
434
|
|
|
435
|
+
## Accessibility notes
|
|
436
|
+
|
|
437
|
+
- The `<table>` is labelled by the visible `<h2>` heading through `aria-labelledby`, so screen readers announce the same month text you see - exactly once, instead of a duplicated `aria-label`.
|
|
438
|
+
- In interactive mode the heading itself is the live region (`aria-live="polite"` + `aria-atomic="true"`), so navigating to another month is announced (WAI-ARIA APG Date Picker Dialog). The month name is **not** copied into a separate hidden element, which would put it into the accessibility tree twice.
|
|
439
|
+
- In interactive mode the table becomes `role="grid"` with `role="gridcell"` cells; the non-interactive table keeps native table semantics.
|
|
440
|
+
- Padding cells carry the `is-blank` class instead of relying on `td:empty`, so grid lines do not break when a renderer emits stray whitespace or comments inside a cell.
|
|
441
|
+
- Heading `id` values come from React's `useId()`, so several calendars of the same month can coexist on one page without duplicate ids.
|
|
442
|
+
- All colour schemes keep text at 4.5:1 or better against its background; grid borders target 2:1 (decorative), and `prefers-reduced-motion` / `forced-colors` are honoured.
|
|
443
|
+
|
|
352
444
|
## Cell Classes
|
|
353
445
|
|
|
354
|
-
Each day cell gets semantic classes you can target with CSS. In interactive mode, the grid is exposed as a `role="grid"` table with `role="gridcell"` cells (WAI-ARIA APG calendar pattern): today's cell gets `aria-current="date"`, the selected date gets `aria-selected
|
|
446
|
+
Each day cell gets semantic classes you can target with CSS. The table is labelled by the visible `<h2>` heading via `aria-labelledby`, weekday headers use `scope="col"`, and week-number cells use `th[scope="row"]`. In interactive mode, the grid is exposed as a `role="grid"` table with `role="gridcell"` cells (WAI-ARIA APG calendar pattern): today's cell gets `aria-current="date"`, the selected date gets `aria-selected` on the gridcell and `aria-pressed` on its button, and only the cursor cell is tabbable (`tabIndex=0`, roving tabindex).
|
|
355
447
|
|
|
356
448
|
| Class | When |
|
|
357
449
|
| :--- | :--- |
|
|
358
450
|
| `is-weekend` | Saturday or Sunday |
|
|
451
|
+
| `is-holiday` | Holiday per `holidayLocale` (default `"ja"`) |
|
|
359
452
|
| `is-today` | Matches `today` |
|
|
360
453
|
| `is-highlight` | Matches `highlight` |
|
|
361
454
|
| `is-in-range` | Inside `range` |
|
|
362
455
|
| `is-in-range-preview` | Inside `rangePreview` |
|
|
363
456
|
| `is-hovered` | Matches `hoveredDate` (interactive mode) |
|
|
457
|
+
| `is-disabled` | Date returned `true` from `isDateDisabled` (interactive mode) |
|
|
364
458
|
|
|
365
459
|
## Exports
|
|
366
460
|
|
|
@@ -368,11 +462,16 @@ Each day cell gets semantic classes you can target with CSS. In interactive mode
|
|
|
368
462
|
import Calendar, {
|
|
369
463
|
Calendar,
|
|
370
464
|
COLOR_SCHEMES,
|
|
465
|
+
getBlankClasses,
|
|
466
|
+
getCellClasses,
|
|
467
|
+
getCellStateClasses,
|
|
468
|
+
getSelectionCellClasses,
|
|
469
|
+
InteractiveCalendar,
|
|
470
|
+
joinCellClassLists,
|
|
371
471
|
resolveColorScheme,
|
|
372
472
|
resolveTheme,
|
|
373
473
|
THEMES,
|
|
374
474
|
useCalendarState,
|
|
375
|
-
InteractiveCalendar,
|
|
376
475
|
} from "@typescript-calendar-lib/react";
|
|
377
476
|
|
|
378
477
|
import type {
|
|
@@ -380,10 +479,12 @@ import type {
|
|
|
380
479
|
CalendarProps,
|
|
381
480
|
CalendarSize,
|
|
382
481
|
CalendarSizeName,
|
|
482
|
+
CellStateOptions,
|
|
383
483
|
ColorSchemeName,
|
|
384
484
|
InteractiveCalendarProps,
|
|
385
485
|
ReactColorScheme,
|
|
386
486
|
ReactTheme,
|
|
487
|
+
SelectionCellOptions,
|
|
387
488
|
ThemeName,
|
|
388
489
|
UseCalendarStateOptions,
|
|
389
490
|
UseCalendarStateReturn,
|
package/dist/calendar.css
CHANGED
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
--cal-bg: #fff;
|
|
3
3
|
--cal-fg: #1e293b;
|
|
4
4
|
--cal-accent: #dc2626;
|
|
5
|
-
--cal-weekend-fg: #
|
|
6
|
-
--cal-
|
|
5
|
+
--cal-weekend-fg: #586a84;
|
|
6
|
+
--cal-holiday-fg: #d33;
|
|
7
|
+
--cal-border: #aeb8c6;
|
|
7
8
|
--cal-header-bg: #f8fafc;
|
|
8
9
|
--cal-highlight-bg: #dc2626;
|
|
9
10
|
--cal-highlight-fg: #fff;
|
|
10
11
|
--cal-range-bg: #fef3c7;
|
|
12
|
+
--cal-range-preview-bg: #fef9c3;
|
|
13
|
+
--cal-hover-bg: #fef9c3;
|
|
11
14
|
--cal-today-bg: #fff7ed;
|
|
12
15
|
--cal-today-fg: #c2410c;
|
|
13
16
|
--cal-selected-bg: #dc2626;
|
|
14
17
|
--cal-selected-fg: #fff;
|
|
15
|
-
--cal-disabled-fg: #
|
|
18
|
+
--cal-disabled-fg: #5b799d;
|
|
16
19
|
--cal-cell-w: 2.25rem;
|
|
17
20
|
--cal-cell-h: 2rem;
|
|
18
21
|
--cal-font-size: .875rem;
|
|
@@ -43,6 +46,14 @@
|
|
|
43
46
|
font-weight: 600;
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
.calendar th.calendar-week, .calendar td.calendar-week {
|
|
50
|
+
width: calc(var(--cal-cell-w) * .6);
|
|
51
|
+
min-width: 1.25rem;
|
|
52
|
+
color: var(--cal-weekend-fg);
|
|
53
|
+
font-size: .75rem;
|
|
54
|
+
font-weight: 400;
|
|
55
|
+
}
|
|
56
|
+
|
|
46
57
|
.calendar .calendar-header {
|
|
47
58
|
text-align: center;
|
|
48
59
|
margin-bottom: .5rem;
|
|
@@ -60,9 +71,12 @@
|
|
|
60
71
|
color: var(--cal-weekend-fg);
|
|
61
72
|
}
|
|
62
73
|
|
|
74
|
+
.calendar td.is-holiday {
|
|
75
|
+
color: var(--cal-holiday-fg, #d33);
|
|
76
|
+
}
|
|
77
|
+
|
|
63
78
|
.calendar td.is-disabled {
|
|
64
79
|
color: var(--cal-disabled-fg, var(--cal-weekend-fg));
|
|
65
|
-
opacity: .5;
|
|
66
80
|
text-decoration: line-through;
|
|
67
81
|
}
|
|
68
82
|
|
|
@@ -155,7 +169,7 @@
|
|
|
155
169
|
border: 1px solid var(--cal-border);
|
|
156
170
|
}
|
|
157
171
|
|
|
158
|
-
.calendar-theme-modern td
|
|
172
|
+
.calendar-theme-modern td.is-blank {
|
|
159
173
|
background: none;
|
|
160
174
|
border-color: #0000;
|
|
161
175
|
}
|
|
@@ -210,11 +224,11 @@
|
|
|
210
224
|
border-radius: 999px;
|
|
211
225
|
}
|
|
212
226
|
|
|
213
|
-
.calendar-theme-rounded td
|
|
227
|
+
.calendar-theme-rounded td.is-blank {
|
|
214
228
|
background: none;
|
|
215
229
|
}
|
|
216
230
|
|
|
217
|
-
.calendar-interactive {
|
|
231
|
+
.calendar-interactive:focus:not(:focus-visible) {
|
|
218
232
|
outline: none;
|
|
219
233
|
}
|
|
220
234
|
|
|
@@ -330,8 +344,63 @@
|
|
|
330
344
|
@media (width <= 360px) {
|
|
331
345
|
.calendar-responsive {
|
|
332
346
|
--cal-cell-w: 1.5rem;
|
|
333
|
-
--cal-cell-h: 1.
|
|
347
|
+
--cal-cell-h: 1.5rem;
|
|
334
348
|
--cal-font-size: .6875rem;
|
|
335
349
|
--cal-header-font-size: .875rem;
|
|
336
350
|
}
|
|
337
351
|
}
|
|
352
|
+
|
|
353
|
+
.calendar-sr-only {
|
|
354
|
+
clip-path: inset(50%);
|
|
355
|
+
white-space: nowrap;
|
|
356
|
+
border: 0;
|
|
357
|
+
width: 1px;
|
|
358
|
+
height: 1px;
|
|
359
|
+
margin: -1px;
|
|
360
|
+
padding: 0;
|
|
361
|
+
position: absolute;
|
|
362
|
+
overflow: hidden;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
@media (prefers-reduced-motion: reduce) {
|
|
366
|
+
.calendar-interactive td button.calendar-day-btn {
|
|
367
|
+
transition: none;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.calendar-interactive td button.calendar-day-btn:active {
|
|
371
|
+
transform: none;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
@media (forced-colors: active) {
|
|
376
|
+
.calendar td.is-today, .calendar td.is-highlight, .calendar td.is-in-range, .calendar td.is-in-range-preview {
|
|
377
|
+
color: canvastext;
|
|
378
|
+
forced-color-adjust: none;
|
|
379
|
+
background: canvas;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.calendar td.is-in-range, .calendar td.is-in-range-preview {
|
|
383
|
+
border: 1px dashed highlight;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.calendar td.is-in-range-preview {
|
|
387
|
+
border-style: dotted;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.calendar td.is-selected {
|
|
391
|
+
color: highlighttext;
|
|
392
|
+
forced-color-adjust: none;
|
|
393
|
+
outline-offset: -2px;
|
|
394
|
+
background: highlight;
|
|
395
|
+
outline: 2px solid highlight;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.calendar td.is-disabled {
|
|
399
|
+
color: graytext;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
.calendar td.is-cursor, .calendar-interactive td button.calendar-day-btn:focus-visible {
|
|
403
|
+
outline-offset: -2px;
|
|
404
|
+
outline: 2px solid canvastext;
|
|
405
|
+
}
|
|
406
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { CalendarState, CalendarStateOptions, Direction, MonthDirection } from "@typescript-calendar-lib/tui";
|
|
1
|
+
import { COLOR_SCHEMES, CalendarCustomSize, CalendarSize, CalendarSizeName, CellStateOptions, ColorSchemeName, SelectionCellOptions, THEMES, ThemeName, WebColorScheme, WebTheme, getBlankClasses, getCellClasses, getCellStateClasses, getSelectionCellClasses, joinCellClassLists, resolveColorScheme, resolveTheme } from "@typescript-calendar-lib/web";
|
|
2
|
+
import { CalendarCellState, CalendarOptions, DateRange } from "@typescript-calendar-lib/core";
|
|
4
3
|
import { CSSProperties, KeyboardEvent, ReactNode, Ref } from "react";
|
|
4
|
+
import { CalendarState, CalendarStateOptions, Direction, MonthDirection, SelectionMode } from "@typescript-calendar-lib/tui";
|
|
5
5
|
//#region src/themes.d.ts
|
|
6
6
|
/** React の見た目定義(web の WebTheme と同一構造) */
|
|
7
7
|
type ReactTheme = WebTheme;
|
|
@@ -13,7 +13,10 @@ interface CalendarProps {
|
|
|
13
13
|
year: number;
|
|
14
14
|
month: number;
|
|
15
15
|
locale?: CalendarOptions["locale"];
|
|
16
|
+
holidayLocale?: CalendarOptions["holidayLocale"];
|
|
16
17
|
weekStart?: CalendarOptions["weekStart"];
|
|
18
|
+
/** 各週の先頭に週番号(ISO/年始基準)を表示する。既定は false */
|
|
19
|
+
showWeekNumbers?: boolean;
|
|
17
20
|
highlight?: Date;
|
|
18
21
|
/** 範囲強調 */
|
|
19
22
|
range?: {
|
|
@@ -47,7 +50,7 @@ interface CalendarProps {
|
|
|
47
50
|
onDateLeave?: () => void;
|
|
48
51
|
/** キーボード操作。root 要素で発火(矢印キー等を InteractiveCalendar が処理する) */
|
|
49
52
|
onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
50
|
-
/** 選択済み日付。aria-selected と表示スタイルに使用 */
|
|
53
|
+
/** 選択済み日付。aria-selected・aria-pressed と表示スタイルに使用 */
|
|
51
54
|
selectedDate?: Date | null;
|
|
52
55
|
/** カーソル位置の日付。このセルだけ tabIndex=0(roving tabindex)になる */
|
|
53
56
|
cursorDate?: Date | null;
|
|
@@ -63,10 +66,10 @@ interface CalendarProps {
|
|
|
63
66
|
ref?: Ref<HTMLDivElement>;
|
|
64
67
|
}
|
|
65
68
|
/** 月カレンダーコンポーネント */
|
|
66
|
-
export declare function Calendar({ year, month, locale, weekStart, highlight, range, today, theme, colorScheme, size, responsive, style, interactive, onDateClick, onDateHover, onDateLeave, onKeyDown, selectedDate, cursorDate, hoveredDate, renderCell, cellData, isDateDisabled, rangePreview, ref }: CalendarProps): import("react").JSX.Element;
|
|
69
|
+
export declare function Calendar({ year, month, locale, holidayLocale, weekStart, showWeekNumbers, highlight, range, today, theme, colorScheme, size, responsive, style, interactive, onDateClick, onDateHover, onDateLeave, onKeyDown, selectedDate, cursorDate, hoveredDate, renderCell, cellData, isDateDisabled, rangePreview, ref }: CalendarProps): import("react").JSX.Element;
|
|
67
70
|
//#endregion
|
|
68
71
|
//#region src/hooks.d.ts
|
|
69
|
-
interface UseCalendarStateOptions extends Pick<CalendarStateOptions, "locale" | "weekStart" | "today" | "highlight" | "range" | "isDateDisabled"> {
|
|
72
|
+
interface UseCalendarStateOptions extends Pick<CalendarStateOptions, "locale" | "holidayLocale" | "weekStart" | "today" | "highlight" | "range" | "isDateDisabled" | "selectionMode"> {
|
|
70
73
|
initialYear?: number;
|
|
71
74
|
initialMonth?: number;
|
|
72
75
|
/** 表示中の年月が変わったときに呼ばれる */
|
|
@@ -94,12 +97,16 @@ interface UseCalendarStateReturn {
|
|
|
94
97
|
setCursorToDate: (date: Date) => void;
|
|
95
98
|
/** 指定した日付を選択し、カーソルもそこへ移動する(当月に無ければ何もしない) */
|
|
96
99
|
selectDateAt: (date: Date) => void;
|
|
100
|
+
/** 範囲を直接設定して選択する(from/to は自動で整列される) */
|
|
101
|
+
selectRange: (from: Date, to: Date) => void;
|
|
97
102
|
/** 選択を解除 */
|
|
98
103
|
clearSelection: () => void;
|
|
99
104
|
/** カーソル位置の日付(null の場合あり) */
|
|
100
105
|
cursorDate: Date | null;
|
|
101
106
|
/** 選択済み日付(null の場合あり) */
|
|
102
107
|
selectedDate: Date | null;
|
|
108
|
+
/** 確定した選択範囲(range モードで確定した範囲)。未確定なら null */
|
|
109
|
+
selectedRange: DateRange | null;
|
|
103
110
|
/** ホバー中の日付(null の場合あり) */
|
|
104
111
|
hoveredDate: Date | null;
|
|
105
112
|
/** ホバー日付を更新する */
|
|
@@ -109,7 +116,7 @@ interface UseCalendarStateReturn {
|
|
|
109
116
|
* tui の不変状態マシンを包む React hook。
|
|
110
117
|
* カレンダーのインタラクティブ操作をシンプルに利用できる。
|
|
111
118
|
*
|
|
112
|
-
* `options` の値(locale / weekStart / today / highlight / range /
|
|
119
|
+
* `options` の値(locale / weekStart / today / highlight / range / selectionMode /
|
|
113
120
|
* initialYear / initialMonth)が変わると、カーソル・選択を保ったまま
|
|
114
121
|
* 状態が再構築される。比較は値(Date は getTime)で行うため、インラインで
|
|
115
122
|
* オプションを渡しても値が同じなら再構築されない。
|
|
@@ -126,7 +133,12 @@ interface InteractiveCalendarProps {
|
|
|
126
133
|
/** 表示開始月 (1-12)。範囲外は正規化される */
|
|
127
134
|
initialMonth?: number;
|
|
128
135
|
locale?: CalendarOptions["locale"];
|
|
136
|
+
holidayLocale?: CalendarOptions["holidayLocale"];
|
|
129
137
|
weekStart?: CalendarOptions["weekStart"];
|
|
138
|
+
/** 各週の先頭に週番号(ISO/年始基準)を表示する */
|
|
139
|
+
showWeekNumbers?: boolean;
|
|
140
|
+
/** 選択方式。既定は "single"。範囲選択時はクリックのたびにアンカー→確定→リセットを交互に行う */
|
|
141
|
+
selectionMode?: SelectionMode;
|
|
130
142
|
/** ハイライト対象日 */
|
|
131
143
|
highlight?: Date;
|
|
132
144
|
/** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスで視覚化される */
|
|
@@ -168,5 +180,5 @@ interface InteractiveCalendarProps {
|
|
|
168
180
|
*/
|
|
169
181
|
export declare function InteractiveCalendar(props: InteractiveCalendarProps): import("react").JSX.Element;
|
|
170
182
|
//#endregion
|
|
171
|
-
export { COLOR_SCHEMES, Calendar as default, type CalendarCustomSize, type CalendarProps, type CalendarSize, type CalendarSizeName, type ColorSchemeName, type InteractiveCalendarProps, type ReactColorScheme, type ReactTheme, THEMES, type ThemeName, type UseCalendarStateOptions, type UseCalendarStateReturn, resolveColorScheme, resolveTheme };
|
|
183
|
+
export { COLOR_SCHEMES, Calendar as default, type CalendarCustomSize, type CalendarProps, type CalendarSize, type CalendarSizeName, type CellStateOptions, type ColorSchemeName, type InteractiveCalendarProps, type ReactColorScheme, type ReactTheme, type SelectionCellOptions, THEMES, type ThemeName, type UseCalendarStateOptions, type UseCalendarStateReturn, getBlankClasses, getCellClasses, getCellStateClasses, getSelectionCellClasses, joinCellClassLists, resolveColorScheme, resolveTheme };
|
|
172
184
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { COLOR_SCHEMES, THEMES, buildSizeStyle, formatCellLabel, getBlankClasses, getBlankClasses as getBlankClasses$1, getCellClasses, getCellStateClasses, getCellStateClasses as getCellStateClasses$1, getSelectionCellClasses, getSelectionCellClasses as getSelectionCellClasses$1, isSizeName, joinCellClassLists, joinCellClassLists as joinCellClassLists$1, mergeColorScheme, resolveColorScheme, resolveTheme, uiString } from "@typescript-calendar-lib/web";
|
|
2
|
+
import { addDays, buildMonthGrid, createDate, getCalendarCellState, getISOWeek, getMonthName, getWeekOfYear, getWeekdayHeaders, isSameDay, sortRange as buildRangePreview } from "@typescript-calendar-lib/core";
|
|
3
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
3
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { clearSelection, createCalendarState, getCursorDate, getSelectedDate, goToDate, goToMonth, goToToday, keyToAction, moveCursor, navigateMonth, navigateYear, sameStateOptions, selectDate, selectDateAt, setCursorToDate, updateStateOptions } from "@typescript-calendar-lib/tui";
|
|
5
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
6
|
-
//#region src/cell-classes.ts
|
|
7
|
-
/** 日付セルの状態(週末・今日・ハイライト・範囲・選択・カーソル)に応じた CSS クラスを組み立てる */
|
|
8
|
-
function getCellClasses(date, options) {
|
|
9
|
-
const state = getCalendarCellState(date, options);
|
|
10
|
-
const classes = [];
|
|
11
|
-
if (state.isWeekend) classes.push("is-weekend");
|
|
12
|
-
if (state.isToday) classes.push("is-today");
|
|
13
|
-
if (state.isHighlight) classes.push("is-highlight");
|
|
14
|
-
if (state.isInRange) classes.push("is-in-range");
|
|
15
|
-
if (options.rangePreview !== void 0 && isDateInRange(date, options.rangePreview)) classes.push("is-in-range-preview");
|
|
16
|
-
if (state.isDisabled) classes.push("is-disabled");
|
|
17
|
-
if (options.hoveredDate != null && isSameDay(date, options.hoveredDate)) classes.push("is-hovered");
|
|
18
|
-
if (options.selected != null && isSameDay(date, options.selected)) classes.push("is-selected");
|
|
19
|
-
if (options.cursorDate != null && isSameDay(date, options.cursorDate)) classes.push("is-cursor");
|
|
20
|
-
return classes.join(" ");
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
5
|
+
import { clearSelection, createCalendarState, getCursorDate, getSelectedDate, getSelectedRange, goToDate, goToMonth, goToToday, keyToAction, moveCursor, navigateMonth, navigateYear, sameStateOptions, selectDate, selectDateAt, selectRange, setCursorToDate, updateStateOptions } from "@typescript-calendar-lib/tui";
|
|
23
6
|
//#region src/size.ts
|
|
24
7
|
/** セルサイズを CSS 変数スタイル(--cal-cell-w / --cal-cell-h)へ変換する */
|
|
25
8
|
function buildSizeStyle$1(size) {
|
|
@@ -28,83 +11,112 @@ function buildSizeStyle$1(size) {
|
|
|
28
11
|
//#endregion
|
|
29
12
|
//#region src/Calendar.tsx
|
|
30
13
|
/** 月カレンダーコンポーネント */
|
|
31
|
-
function Calendar({ year, month, locale = "en", weekStart = "sunday", highlight, range, today, theme = "default", colorScheme = "default", size = "md", responsive = false, style, interactive = false, onDateClick, onDateHover, onDateLeave, onKeyDown, selectedDate = null, cursorDate = null, hoveredDate = null, renderCell, cellData, isDateDisabled, rangePreview, ref }) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
selected: selectedDate,
|
|
40
|
-
cursorDate,
|
|
41
|
-
isDateDisabled
|
|
42
|
-
}) || void 0;
|
|
43
|
-
const handleCellClick = (day) => {
|
|
44
|
-
if (interactive && onDateClick) {
|
|
45
|
-
const date = cellDate(day);
|
|
46
|
-
onDateClick(date, cellData?.(date));
|
|
47
|
-
}
|
|
14
|
+
function Calendar({ year, month, locale = "en", holidayLocale, weekStart = "sunday", showWeekNumbers = false, highlight, range, today, theme = "default", colorScheme = "default", size = "md", responsive = false, style, interactive = false, onDateClick, onDateHover, onDateLeave, onKeyDown, selectedDate = null, cursorDate = null, hoveredDate = null, renderCell, cellData, isDateDisabled, rangePreview, ref }) {
|
|
15
|
+
const grid = useMemo(() => buildMonthGrid(year, month, weekStart), [
|
|
16
|
+
year,
|
|
17
|
+
month,
|
|
18
|
+
weekStart
|
|
19
|
+
]);
|
|
20
|
+
const handleCellClick = (date, data) => {
|
|
21
|
+
if (interactive && onDateClick) onDateClick(date, data);
|
|
48
22
|
};
|
|
49
|
-
const handleCellHover = (
|
|
50
|
-
if (interactive && onDateHover) onDateHover(
|
|
23
|
+
const handleCellHover = (date) => {
|
|
24
|
+
if (interactive && onDateHover) onDateHover(date);
|
|
51
25
|
};
|
|
52
26
|
const handleMouseLeave = () => {
|
|
53
27
|
if (interactive && onDateLeave) onDateLeave();
|
|
54
28
|
};
|
|
55
29
|
const title = `${getMonthName(locale, month)} ${year}`;
|
|
30
|
+
const weekLabel = uiString("weekNumber", locale);
|
|
31
|
+
const weekOf = (row) => {
|
|
32
|
+
const firstIdx = row.findIndex((d) => d !== null);
|
|
33
|
+
if (firstIdx === -1) return null;
|
|
34
|
+
const firstDate = createDate(year, month - 1, row[firstIdx]);
|
|
35
|
+
const weekStartDate = addDays(firstDate, -firstIdx);
|
|
36
|
+
return weekStart === "monday" ? getISOWeek(weekStartDate) : getWeekOfYear(weekStartDate);
|
|
37
|
+
};
|
|
56
38
|
const gridRole = interactive ? "grid" : void 0;
|
|
57
39
|
const cellRole = interactive ? "gridcell" : void 0;
|
|
40
|
+
const headingId = useId();
|
|
58
41
|
return /* @__PURE__ */ jsxs("div", {
|
|
59
42
|
ref,
|
|
60
43
|
className: `calendar ${resolveTheme(theme).className}${isSizeName(size) ? ` calendar-size-${size}` : ""}${interactive ? " calendar-interactive" : ""}${responsive ? " calendar-responsive" : ""}`,
|
|
61
44
|
onMouseLeave: interactive ? handleMouseLeave : void 0,
|
|
62
45
|
style: {
|
|
63
|
-
...
|
|
46
|
+
...mergeColorScheme(colorScheme),
|
|
64
47
|
...buildSizeStyle$1(size),
|
|
65
48
|
...style
|
|
66
49
|
},
|
|
67
50
|
children: [/* @__PURE__ */ jsx("div", {
|
|
68
51
|
className: "calendar-header",
|
|
69
|
-
children: /* @__PURE__ */ jsx("h2", {
|
|
52
|
+
children: /* @__PURE__ */ jsx("h2", {
|
|
53
|
+
id: headingId,
|
|
54
|
+
"aria-live": gridRole ? "polite" : void 0,
|
|
55
|
+
"aria-atomic": gridRole ? "true" : void 0,
|
|
56
|
+
children: title
|
|
57
|
+
})
|
|
70
58
|
}), /* @__PURE__ */ jsxs("table", {
|
|
71
59
|
role: gridRole,
|
|
72
|
-
"aria-
|
|
60
|
+
"aria-labelledby": headingId,
|
|
73
61
|
onKeyDown,
|
|
74
|
-
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */
|
|
62
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [showWeekNumbers && /* @__PURE__ */ jsx("th", {
|
|
63
|
+
className: "calendar-week",
|
|
64
|
+
scope: "col",
|
|
65
|
+
"aria-label": uiString("weekNumber", locale)
|
|
66
|
+
}, "week"), getWeekdayHeaders(locale, weekStart).map((day) => /* @__PURE__ */ jsx("th", {
|
|
67
|
+
scope: "col",
|
|
68
|
+
children: day
|
|
69
|
+
}, day))] }) }), /* @__PURE__ */ jsx("tbody", { children: grid.map((row, i) => {
|
|
75
70
|
if (row.every((d) => d === null)) return null;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
const week = weekOf(row);
|
|
72
|
+
return /* @__PURE__ */ jsxs("tr", { children: [showWeekNumbers && week !== null && /* @__PURE__ */ jsx("th", {
|
|
73
|
+
className: "calendar-week",
|
|
74
|
+
scope: "row",
|
|
75
|
+
"aria-label": `${weekLabel} ${week}`,
|
|
76
|
+
children: week
|
|
77
|
+
}, "week"), row.map((day, j) => {
|
|
78
|
+
if (day === null) return /* @__PURE__ */ jsx("td", {
|
|
79
|
+
role: cellRole,
|
|
80
|
+
className: getBlankClasses$1()
|
|
81
|
+
}, `b-${j}`);
|
|
82
|
+
const date = createDate(year, month - 1, day);
|
|
79
83
|
const state = getCalendarCellState(date, {
|
|
80
84
|
today,
|
|
85
|
+
holidayLocale,
|
|
81
86
|
highlight,
|
|
82
87
|
range,
|
|
83
88
|
isDateDisabled
|
|
84
89
|
});
|
|
85
|
-
const
|
|
90
|
+
const className = joinCellClassLists$1(getCellStateClasses$1(state), getSelectionCellClasses$1(date, {
|
|
91
|
+
rangePreview,
|
|
92
|
+
hoveredDate,
|
|
93
|
+
selected: selectedDate,
|
|
94
|
+
cursorDate
|
|
95
|
+
})) || void 0;
|
|
86
96
|
const selected = selectedDate !== null && isSameDay(date, selectedDate);
|
|
87
97
|
const cursor = cursorDate !== null && isSameDay(date, cursorDate);
|
|
98
|
+
const onClick = interactive && !state.isDisabled ? () => handleCellClick(date, cellData?.(date)) : void 0;
|
|
99
|
+
const onEnter = interactive && !state.isDisabled ? () => handleCellHover(date) : void 0;
|
|
88
100
|
return /* @__PURE__ */ jsx("td", {
|
|
89
101
|
role: cellRole,
|
|
90
|
-
|
|
91
|
-
className: className(day),
|
|
102
|
+
className,
|
|
92
103
|
"aria-selected": selected || void 0,
|
|
93
104
|
"aria-current": state.isToday ? "date" : void 0,
|
|
94
105
|
"aria-disabled": state.isDisabled || void 0,
|
|
95
106
|
children: interactive ? /* @__PURE__ */ jsx("button", {
|
|
96
107
|
type: "button",
|
|
97
108
|
className: "calendar-day-btn",
|
|
98
|
-
onClick
|
|
99
|
-
onMouseEnter:
|
|
109
|
+
onClick,
|
|
110
|
+
onMouseEnter: onEnter,
|
|
100
111
|
tabIndex: cursor ? 0 : -1,
|
|
101
112
|
"data-cursor": cursor ? "true" : void 0,
|
|
102
113
|
"aria-label": formatCellLabel(locale, year, month, day),
|
|
114
|
+
"aria-pressed": selected,
|
|
103
115
|
disabled: state.isDisabled,
|
|
104
|
-
children: renderCell ? renderCell(day, date, state,
|
|
105
|
-
}) : renderCell ? renderCell(day, date, state,
|
|
116
|
+
children: renderCell ? renderCell(day, date, state, cellData?.(date)) : day
|
|
117
|
+
}) : renderCell ? renderCell(day, date, state, cellData?.(date)) : day
|
|
106
118
|
}, `d-${day}`);
|
|
107
|
-
}) }, i);
|
|
119
|
+
})] }, i);
|
|
108
120
|
}) })]
|
|
109
121
|
})]
|
|
110
122
|
});
|
|
@@ -115,7 +127,7 @@ function Calendar({ year, month, locale = "en", weekStart = "sunday", highlight,
|
|
|
115
127
|
* tui の不変状態マシンを包む React hook。
|
|
116
128
|
* カレンダーのインタラクティブ操作をシンプルに利用できる。
|
|
117
129
|
*
|
|
118
|
-
* `options` の値(locale / weekStart / today / highlight / range /
|
|
130
|
+
* `options` の値(locale / weekStart / today / highlight / range / selectionMode /
|
|
119
131
|
* initialYear / initialMonth)が変わると、カーソル・選択を保ったまま
|
|
120
132
|
* 状態が再構築される。比較は値(Date は getTime)で行うため、インラインで
|
|
121
133
|
* オプションを渡しても値が同じなら再構築されない。
|
|
@@ -162,9 +174,11 @@ function useCalendarState(options = {}) {
|
|
|
162
174
|
selectDate: useCallback(() => setState((prev) => selectDate(prev)), []),
|
|
163
175
|
setCursorToDate: useCallback((date) => setState((prev) => setCursorToDate(prev, date)), []),
|
|
164
176
|
selectDateAt: useCallback((date) => setState((prev) => selectDateAt(prev, date)), []),
|
|
177
|
+
selectRange: useCallback((from, to) => setState((prev) => selectRange(prev, from, to)), []),
|
|
165
178
|
clearSelection: useCallback(() => setState((prev) => clearSelection(prev)), []),
|
|
166
179
|
cursorDate: getCursorDate(state),
|
|
167
180
|
selectedDate: getSelectedDate(state),
|
|
181
|
+
selectedRange: getSelectedRange(state),
|
|
168
182
|
hoveredDate,
|
|
169
183
|
setHoveredDate
|
|
170
184
|
};
|
|
@@ -181,12 +195,14 @@ function useCalendarState(options = {}) {
|
|
|
181
195
|
* Enter/Space(クリックと同じ日付選択)
|
|
182
196
|
*/
|
|
183
197
|
function InteractiveCalendar(props) {
|
|
184
|
-
const { initialYear, initialMonth, locale, weekStart, highlight, range, today, isDateDisabled, onMonthChange, theme, colorScheme, size, responsive, style, renderCell, cellData, onDateClick, onDateHover, onDateLeave } = props;
|
|
198
|
+
const { initialYear, initialMonth, locale, holidayLocale, weekStart, showWeekNumbers, selectionMode, highlight, range, today, isDateDisabled, onMonthChange, theme, colorScheme, size, responsive, style, renderCell, cellData, onDateClick, onDateHover, onDateLeave } = props;
|
|
185
199
|
const hook = useCalendarState({
|
|
186
200
|
initialYear,
|
|
187
201
|
initialMonth,
|
|
188
202
|
locale,
|
|
203
|
+
holidayLocale,
|
|
189
204
|
weekStart,
|
|
205
|
+
selectionMode,
|
|
190
206
|
today,
|
|
191
207
|
highlight,
|
|
192
208
|
range,
|
|
@@ -207,7 +223,7 @@ function InteractiveCalendar(props) {
|
|
|
207
223
|
setHoveredDate(null);
|
|
208
224
|
onDateLeave?.();
|
|
209
225
|
}, [setHoveredDate, onDateLeave]);
|
|
210
|
-
const rangePreview = buildRangePreview(hook.selectedDate, hook.hoveredDate);
|
|
226
|
+
const rangePreview = hook.selectedRange ?? buildRangePreview(hook.selectedDate, hook.hoveredDate);
|
|
211
227
|
const prevCursorRef = useRef(state.cursor);
|
|
212
228
|
useEffect(() => {
|
|
213
229
|
const prev = prevCursorRef.current;
|
|
@@ -238,7 +254,9 @@ function InteractiveCalendar(props) {
|
|
|
238
254
|
year: state.year,
|
|
239
255
|
month: state.month,
|
|
240
256
|
locale: state.options.locale,
|
|
257
|
+
holidayLocale: state.options.holidayLocale,
|
|
241
258
|
weekStart: state.options.weekStart,
|
|
259
|
+
showWeekNumbers,
|
|
242
260
|
highlight: state.options.highlight,
|
|
243
261
|
range: state.options.range,
|
|
244
262
|
today: state.options.today,
|
|
@@ -262,6 +280,6 @@ function InteractiveCalendar(props) {
|
|
|
262
280
|
});
|
|
263
281
|
}
|
|
264
282
|
//#endregion
|
|
265
|
-
export { COLOR_SCHEMES, Calendar, Calendar as default, InteractiveCalendar, THEMES, resolveColorScheme, resolveTheme, useCalendarState };
|
|
283
|
+
export { COLOR_SCHEMES, Calendar, Calendar as default, InteractiveCalendar, THEMES, getBlankClasses, getCellClasses, getCellStateClasses, getSelectionCellClasses, joinCellClassLists, resolveColorScheme, resolveTheme, useCalendarState };
|
|
266
284
|
|
|
267
285
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["buildSizeStyle","buildSizeStyleBase","buildSizeStyle"],"sources":["../src/cell-classes.ts","../src/size.ts","../src/Calendar.tsx","../src/hooks.ts","../src/interactive.tsx"],"sourcesContent":["import {\n getCalendarCellState,\n isDateInRange,\n isSameDay,\n} from \"@typescript-calendar-lib/core\";\n\n// ─── セル状態クラス ───────────────────────────────────────\n\nexport interface CellStateOptions {\n today?: Date;\n highlight?: Date;\n range?: { from: Date; to: Date };\n /** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスになる */\n rangePreview?: { from: Date; to: Date };\n /** ホバー中の日付。is-hovered クラスになる */\n hoveredDate?: Date | null;\n /** 選択済み日付。該当セルに is-selected クラスが付く */\n selected?: Date | null;\n /** カーソル位置の日付。該当セルに is-cursor クラスが付く */\n cursorDate?: Date | null;\n /** 選択不可日付の判定。該当セルに is-disabled クラスが付く */\n isDateDisabled?: (date: Date) => boolean;\n}\n\n// 範囲の from > to は不正入力として RangeError(isDateInRange が検証する)\n\n/** 日付セルの状態(週末・今日・ハイライト・範囲・選択・カーソル)に応じた CSS クラスを組み立てる */\nexport function getCellClasses(date: Date, options: CellStateOptions): string {\n const state = getCalendarCellState(date, options);\n const classes: string[] = [];\n if (state.isWeekend) classes.push(\"is-weekend\");\n if (state.isToday) classes.push(\"is-today\");\n if (state.isHighlight) classes.push(\"is-highlight\");\n if (state.isInRange) classes.push(\"is-in-range\");\n if (\n options.rangePreview !== undefined &&\n isDateInRange(date, options.rangePreview)\n )\n classes.push(\"is-in-range-preview\");\n if (state.isDisabled) classes.push(\"is-disabled\");\n if (options.hoveredDate != null && isSameDay(date, options.hoveredDate))\n classes.push(\"is-hovered\");\n if (options.selected != null && isSameDay(date, options.selected))\n classes.push(\"is-selected\");\n if (options.cursorDate != null && isSameDay(date, options.cursorDate))\n classes.push(\"is-cursor\");\n return classes.join(\" \");\n}\n","// ─── セルサイズ ───────────────────────────────────────────\n// サイズ判定・CSS 変数変換は web パッケージに集約済み。\n// ここでは React の style 型(CSSProperties)に適合させる薄いアダプタのみ持つ。\n\nimport type { CalendarSize } from \"@typescript-calendar-lib/web\";\nimport type { CSSProperties } from \"react\";\n\nexport type {\n CalendarCustomSize,\n CalendarSize,\n CalendarSizeName,\n} from \"@typescript-calendar-lib/web\";\nexport { isSizeName } from \"@typescript-calendar-lib/web\";\n\nimport { buildSizeStyle as buildSizeStyleBase } from \"@typescript-calendar-lib/web\";\n\n/** セルサイズを CSS 変数スタイル(--cal-cell-w / --cal-cell-h)へ変換する */\nexport function buildSizeStyle(size: CalendarSize): CSSProperties {\n return buildSizeStyleBase(size) as CSSProperties;\n}\n","import type {\n CalendarCellState,\n CalendarOptions,\n} from \"@typescript-calendar-lib/core\";\nimport {\n buildMonthGrid,\n createDate,\n getCalendarCellState,\n getMonthName,\n getWeekdayHeaders,\n isSameDay,\n} from \"@typescript-calendar-lib/core\";\nimport { formatCellLabel } from \"@typescript-calendar-lib/web\";\nimport type {\n CSSProperties,\n KeyboardEvent as ReactKeyboardEvent,\n ReactNode,\n Ref,\n} from \"react\";\nimport { getCellClasses } from \"./cell-classes.ts\";\nimport type { CalendarSize } from \"./size.ts\";\nimport { buildSizeStyle, isSizeName } from \"./size.ts\";\nimport type {\n ColorSchemeName,\n ReactColorScheme,\n ReactTheme,\n ThemeName,\n} from \"./themes.ts\";\nimport { resolveColorScheme, resolveTheme } from \"./themes.ts\";\n\nexport type {\n CalendarCustomSize,\n CalendarSize,\n CalendarSizeName,\n} from \"./size.ts\";\n\nexport interface CalendarProps {\n year: number;\n month: number;\n locale?: CalendarOptions[\"locale\"];\n weekStart?: CalendarOptions[\"weekStart\"];\n highlight?: Date;\n /** 範囲強調 */\n range?: { from: Date; to: Date };\n /** 今日の基準日。カラースキームの today 着色に使用 */\n today?: Date;\n /** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスで視覚化される */\n rangePreview?: { from: Date; to: Date };\n /** 見た目テーマ。既定は \"default\" */\n theme?: ThemeName | ReactTheme;\n /** カラースキーム。既定は \"default\" */\n colorScheme?: ColorSchemeName | ReactColorScheme;\n /** セルサイズ。既定は \"md\"。{ width, height } で自由に指定できる */\n size?: CalendarSize;\n /** 狭い画面(スマホ等)でセルサイズと余白を自動調整する。既定は false(無効) */\n responsive?: boolean;\n /** root 要素に追加するスタイル。CSS変数(--cal-*)で自由に上書きできる */\n style?: CSSProperties;\n\n // ── インタラクション ──\n\n /** インタラクティブモードを有効にする。セルクリック・ホバー・キーボード選択が可能になる */\n interactive?: boolean;\n /** セルクリック時のコールバック。第2引数に該当日のデータ(cellData の戻り値)が渡る */\n onDateClick?: (date: Date, data?: unknown) => void;\n /** セルホバー時のコールバック */\n onDateHover?: (date: Date) => void;\n /** カレンダーからマウスが離れたときのコールバック */\n onDateLeave?: () => void;\n /** キーボード操作。root 要素で発火(矢印キー等を InteractiveCalendar が処理する) */\n onKeyDown?: (event: ReactKeyboardEvent<HTMLDivElement>) => void;\n\n // ── セル状態 ──\n\n /** 選択済み日付。aria-selected と表示スタイルに使用 */\n selectedDate?: Date | null;\n /** カーソル位置の日付。このセルだけ tabIndex=0(roving tabindex)になる */\n cursorDate?: Date | null;\n /** ホバー中の日付。is-hovered クラスで視覚化される */\n hoveredDate?: Date | null;\n /** セル内容のカスタムレンダリング。interactive 時は button の子として描画される。第4引数に該当日のデータが渡る */\n renderCell?: (\n day: number,\n date: Date,\n state: CalendarCellState,\n data?: unknown,\n ) => ReactNode;\n /** 各セルに付与するユーザー定義データを解決する関数。実セルのみに呼ばれる */\n cellData?: (date: Date) => unknown;\n /** 選択不可日付の判定。true を返した日付は is-disabled クラスになり、インタラクティブ時は選択・ホバーできなくなる */\n isDateDisabled?: (date: Date) => boolean;\n\n /** root 要素への ref(React 19 の ref-as-prop) */\n ref?: Ref<HTMLDivElement>;\n}\n\n/** 月カレンダーコンポーネント */\nexport function Calendar({\n year,\n month,\n locale = \"en\",\n weekStart = \"sunday\",\n highlight,\n range,\n today,\n theme = \"default\",\n colorScheme = \"default\",\n size = \"md\",\n responsive = false,\n style,\n interactive = false,\n onDateClick,\n onDateHover,\n onDateLeave,\n onKeyDown,\n selectedDate = null,\n cursorDate = null,\n hoveredDate = null,\n renderCell,\n cellData,\n isDateDisabled,\n rangePreview,\n ref,\n}: CalendarProps) {\n const cellDate = (day: number): Date => createDate(year, month - 1, day);\n const className = (day: number): string | undefined =>\n getCellClasses(cellDate(day), {\n today,\n highlight,\n range,\n rangePreview,\n hoveredDate,\n selected: selectedDate,\n cursorDate,\n isDateDisabled,\n }) || undefined;\n\n const handleCellClick = (day: number) => {\n if (interactive && onDateClick) {\n const date = cellDate(day);\n onDateClick(date, cellData?.(date));\n }\n };\n\n const handleCellHover = (day: number) => {\n if (interactive && onDateHover) onDateHover(cellDate(day));\n };\n\n const handleMouseLeave = () => {\n if (interactive && onDateLeave) onDateLeave();\n };\n\n const title = `${getMonthName(locale, month)} ${year}`;\n // インタラクティブ時のみ APG の grid セマンティクスを付与する。\n // 静的表示ではネイティブの table/cell セマンティクスをそのまま使う。\n const gridRole = interactive ? \"grid\" : undefined;\n const cellRole = interactive ? \"gridcell\" : undefined;\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: onMouseLeave はホバー状態クリア用の補助イベント。キーボード操作(role=grid)は独立して対応済み\n <div\n ref={ref}\n className={`calendar ${resolveTheme(theme).className}${isSizeName(size) ? ` calendar-size-${size}` : \"\"}${interactive ? \" calendar-interactive\" : \"\"}${responsive ? \" calendar-responsive\" : \"\"}`}\n onMouseLeave={interactive ? handleMouseLeave : undefined}\n style={{\n ...(resolveColorScheme(colorScheme) as CSSProperties),\n ...buildSizeStyle(size),\n ...style,\n }}\n >\n <div className=\"calendar-header\">\n <h2>{title}</h2>\n </div>\n <table role={gridRole} aria-label={title} onKeyDown={onKeyDown}>\n <thead>\n <tr>\n {getWeekdayHeaders(locale, weekStart).map((day) => (\n <th key={day}>{day}</th>\n ))}\n </tr>\n </thead>\n <tbody>\n {buildMonthGrid(year, month, weekStart).map((row, i) => {\n if (row.every((d) => d === null)) return null;\n return (\n // biome-ignore lint/suspicious/noArrayIndexKey: 月グリッドは静的で並び順が変わらない\n <tr key={i}>\n {row.map((day, j) => {\n if (day === null)\n // biome-ignore lint/suspicious/noArrayIndexKey: パディングセルは位置が唯一の識別子\n return <td key={j} role={cellRole} />;\n const date = cellDate(day);\n const state = getCalendarCellState(date, {\n today,\n highlight,\n range,\n isDateDisabled,\n });\n const data = cellData?.(date);\n const selected =\n selectedDate !== null && isSameDay(date, selectedDate);\n const cursor =\n cursorDate !== null && isSameDay(date, cursorDate);\n return (\n // biome-ignore lint/a11y/useAriaPropsSupportedByRole: interactive 時は td に role=gridcell が付き aria-selected は有効(role が動的なため静的解析できない)\n <td\n // パディングセル(key=j)との衝突を避けるため日番号に \"d-\" を付与する。日番号は列位置 j と異なり配列の index ではない\n key={`d-${day}`}\n role={cellRole}\n tabIndex={interactive ? -1 : undefined}\n className={className(day)}\n aria-selected={selected || undefined}\n aria-current={state.isToday ? \"date\" : undefined}\n aria-disabled={state.isDisabled || undefined}\n >\n {interactive ? (\n <button\n type=\"button\"\n className=\"calendar-day-btn\"\n onClick={\n state.isDisabled\n ? undefined\n : () => handleCellClick(day)\n }\n onMouseEnter={\n state.isDisabled\n ? undefined\n : () => handleCellHover(day)\n }\n tabIndex={cursor ? 0 : -1}\n data-cursor={cursor ? \"true\" : undefined}\n aria-label={formatCellLabel(locale, year, month, day)}\n disabled={state.isDisabled}\n >\n {renderCell\n ? renderCell(day, date, state, data)\n : day}\n </button>\n ) : renderCell ? (\n renderCell(day, date, state, data)\n ) : (\n day\n )}\n </td>\n );\n })}\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n}\n\nexport default Calendar;\n","import type {\n CalendarState,\n CalendarStateOptions,\n Direction,\n MonthDirection,\n} from \"@typescript-calendar-lib/tui\";\nimport {\n clearSelection,\n createCalendarState,\n getCursorDate,\n getSelectedDate,\n goToDate,\n goToMonth,\n goToToday,\n moveCursor,\n navigateMonth,\n navigateYear,\n sameStateOptions,\n selectDate,\n selectDateAt,\n setCursorToDate,\n updateStateOptions,\n} from \"@typescript-calendar-lib/tui\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport interface UseCalendarStateOptions\n extends Pick<\n CalendarStateOptions,\n \"locale\" | \"weekStart\" | \"today\" | \"highlight\" | \"range\" | \"isDateDisabled\"\n > {\n initialYear?: number;\n initialMonth?: number;\n /** 表示中の年月が変わったときに呼ばれる */\n onMonthChange?: (year: number, month: number) => void;\n}\n\nexport interface UseCalendarStateReturn {\n /** 現在のカレンダー状態 */\n state: CalendarState;\n /** カーソルを指定方向に移動 (wrap around) */\n moveCursor: (direction: Direction) => void;\n /** 前月/翌月へ移動 */\n goNext: () => void;\n goPrev: () => void;\n /** 前年/翌年へ移動 */\n navigateYear: (direction: MonthDirection) => void;\n /** 指定した年月へジャンプ */\n goToMonth: (year: number, month: number) => void;\n /** 指定した日付の月へジャンプし、カーソルをその日付に置く */\n goToDate: (date: Date) => void;\n /** 今日の月へジャンプ */\n goToday: () => void;\n /** カーソル位置の日付を選択 */\n selectDate: () => void;\n /** 指定した日付へカーソルを移動する(当月に無ければ何もしない) */\n setCursorToDate: (date: Date) => void;\n /** 指定した日付を選択し、カーソルもそこへ移動する(当月に無ければ何もしない) */\n selectDateAt: (date: Date) => void;\n /** 選択を解除 */\n clearSelection: () => void;\n /** カーソル位置の日付(null の場合あり) */\n cursorDate: Date | null;\n /** 選択済み日付(null の場合あり) */\n selectedDate: Date | null;\n /** ホバー中の日付(null の場合あり) */\n hoveredDate: Date | null;\n /** ホバー日付を更新する */\n setHoveredDate: (date: Date | null) => void;\n}\n\n/**\n * tui の不変状態マシンを包む React hook。\n * カレンダーのインタラクティブ操作をシンプルに利用できる。\n *\n * `options` の値(locale / weekStart / today / highlight / range /\n * initialYear / initialMonth)が変わると、カーソル・選択を保ったまま\n * 状態が再構築される。比較は値(Date は getTime)で行うため、インラインで\n * オプションを渡しても値が同じなら再構築されない。\n *\n * `today` を省略した場合、最初に解決された値が状態に固定され、以降も\n * 引き継がれる(毎レンダリング `new Date()` を渡さなくてよい)。\n */\nexport function useCalendarState(\n options: UseCalendarStateOptions = {},\n): UseCalendarStateReturn {\n const [state, setState] = useState<CalendarState>(() =>\n createCalendarState(options),\n );\n\n // ホバー中の日付は React ローカル state で保持する(tui 状態には入れない)。\n const [hoveredDate, setHoveredDate] = useState<Date | null>(null);\n\n // options の「値の変化」を検知して状態を再構築する。\n // 初回は prevOptions が同一なので何もしない。値が同じままの再レンダリング\n // でも何もしないため、インラインリテラルを毎回渡しても無限ループしない。\n const prevOptions = useRef(options);\n useEffect(() => {\n if (sameStateOptions(prevOptions.current, options)) return;\n const previous = prevOptions.current;\n prevOptions.current = options;\n setState((current) => updateStateOptions(current, options, previous));\n }, [options]);\n\n // onMonthChange: ref 経由で安定参照\n const onMonthChangeRef = useRef(options.onMonthChange);\n onMonthChangeRef.current = options.onMonthChange;\n\n // 表示月が変わったら onMonthChange を通知し、古い月を指すホバーをクリアする\n const prevMonthRef = useRef({ year: state.year, month: state.month });\n useEffect(() => {\n const prev = prevMonthRef.current;\n if (prev.year !== state.year || prev.month !== state.month) {\n prevMonthRef.current = { year: state.year, month: state.month };\n onMonthChangeRef.current?.(state.year, state.month);\n setHoveredDate(null);\n }\n }, [state.year, state.month]);\n\n return {\n state,\n moveCursor: useCallback(\n (direction: Direction) => setState((prev) => moveCursor(prev, direction)),\n [],\n ),\n goNext: useCallback(\n () => setState((prev) => navigateMonth(prev, \"next\")),\n [],\n ),\n goPrev: useCallback(\n () => setState((prev) => navigateMonth(prev, \"prev\")),\n [],\n ),\n navigateYear: useCallback(\n (direction: MonthDirection) =>\n setState((prev) => navigateYear(prev, direction)),\n [],\n ),\n goToMonth: useCallback(\n (year: number, month: number) =>\n setState((prev) => goToMonth(prev, year, month)),\n [],\n ),\n goToDate: useCallback(\n (date: Date) => setState((prev) => goToDate(prev, date)),\n [],\n ),\n goToday: useCallback(() => setState((prev) => goToToday(prev)), []),\n selectDate: useCallback(() => setState((prev) => selectDate(prev)), []),\n setCursorToDate: useCallback(\n (date: Date) => setState((prev) => setCursorToDate(prev, date)),\n [],\n ),\n selectDateAt: useCallback(\n (date: Date) => setState((prev) => selectDateAt(prev, date)),\n [],\n ),\n clearSelection: useCallback(\n () => setState((prev) => clearSelection(prev)),\n [],\n ),\n cursorDate: getCursorDate(state),\n selectedDate: getSelectedDate(state),\n hoveredDate,\n setHoveredDate,\n };\n}\n\nexport type { Direction, MonthDirection };\n","import type { CalendarOptions } from \"@typescript-calendar-lib/core\";\nimport { keyToAction } from \"@typescript-calendar-lib/tui\";\nimport type { CSSProperties } from \"react\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { Calendar, type CalendarProps } from \"./Calendar.tsx\";\nimport { useCalendarState } from \"./hooks.ts\";\nimport { buildRangePreview } from \"./range-preview.ts\";\nimport type { CalendarSize } from \"./size.ts\";\nimport type {\n ColorSchemeName,\n ReactColorScheme,\n ReactTheme,\n ThemeName,\n} from \"./themes.ts\";\n\nexport interface InteractiveCalendarProps {\n // ── useCalendarState オプション ──\n\n /** 表示開始年。既定は today の年 */\n initialYear?: number;\n /** 表示開始月 (1-12)。範囲外は正規化される */\n initialMonth?: number;\n locale?: CalendarOptions[\"locale\"];\n weekStart?: CalendarOptions[\"weekStart\"];\n /** ハイライト対象日 */\n highlight?: Date;\n /** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスで視覚化される */\n range?: { from: Date; to: Date };\n /** 今日の基準日。省略時は初回レンダリング時刻に解決される */\n today?: Date;\n /** 選択不可日付の判定。true を返した日付は選択・カーソル移動・ホバーの対象外になる */\n isDateDisabled?: (date: Date) => boolean;\n /** 表示中の年月が変わったときに呼ばれる */\n onMonthChange?: (year: number, month: number) => void;\n\n // ── Calendar の見た目 ──\n\n theme?: ThemeName | ReactTheme;\n colorScheme?: ColorSchemeName | ReactColorScheme;\n size?: CalendarSize;\n /** 狭い画面(スマホ等)でセルサイズと余白を自動調整する */\n responsive?: boolean;\n style?: CSSProperties;\n /** セル内容のカスタムレンダリング。第4引数に該当日のデータが渡る */\n renderCell?: CalendarProps[\"renderCell\"];\n /** 各セルに付与するユーザー定義データを解決する関数。実セルのみに呼ばれる */\n cellData?: (date: Date) => unknown;\n\n // ── イベント ──\n\n /** セルクリック時(キーボードの Enter/Space 含む)。クリックした日付は自動的に選択される。第2引数に該当日のデータが渡る */\n onDateClick?: (date: Date, data?: unknown) => void;\n /** セルホバー時 */\n onDateHover?: (date: Date) => void;\n /** カレンダーからマウスが離れたとき */\n onDateLeave?: () => void;\n}\n\n/**\n * `useCalendarState` と `Calendar` を一体化したインタラクティブカレンダー。\n * 内部で状態を管理し、以下の操作に対応する:\n *\n * - マウス: セルクリックで日付を選択(カーソルもそこへ移動) / ホバー追跡 /\n * 選択済み日付とホバー日付の間を範囲プレビュー表示\n * - キーボード: 矢印キー(カーソル移動)・PageUp/PageDown(月移動)・\n * Enter/Space(クリックと同じ日付選択)\n */\nexport function InteractiveCalendar(props: InteractiveCalendarProps) {\n const {\n initialYear,\n initialMonth,\n locale,\n weekStart,\n highlight,\n range,\n today,\n isDateDisabled,\n onMonthChange,\n theme,\n colorScheme,\n size,\n responsive,\n style,\n renderCell,\n cellData,\n onDateClick,\n onDateHover,\n onDateLeave,\n } = props;\n\n const hook = useCalendarState({\n initialYear,\n initialMonth,\n locale,\n weekStart,\n today,\n highlight,\n range,\n isDateDisabled,\n onMonthChange,\n });\n\n const { state, moveCursor, goPrev, goNext, selectDateAt, setHoveredDate } =\n hook;\n const rootRef = useRef<HTMLDivElement>(null);\n\n // クリック(マウス・Enter/Space 共通)で日付を選択する。\n // 従来の onDateClick コールバックも引き続き発火し、第2引数に該当日のデータが渡る。\n const handleDateClick = useCallback(\n (date: Date, data?: unknown) => {\n selectDateAt(date);\n onDateClick?.(date, data);\n },\n [selectDateAt, onDateClick],\n );\n\n const handleDateHover = useCallback(\n (date: Date) => {\n setHoveredDate(date);\n onDateHover?.(date);\n },\n [setHoveredDate, onDateHover],\n );\n\n const handleDateLeave = useCallback(() => {\n setHoveredDate(null);\n onDateLeave?.();\n }, [setHoveredDate, onDateLeave]);\n\n // 選択済み日付とホバー日付の間を範囲プレビューとして表示する\n const rangePreview = buildRangePreview(hook.selectedDate, hook.hoveredDate);\n\n // カーソルが動いたときだけ、そのセルへフォーカスを移す(初回マウントでは動かさない)\n const prevCursorRef = useRef(state.cursor);\n useEffect(() => {\n const prev = prevCursorRef.current;\n prevCursorRef.current = state.cursor;\n if (prev === state.cursor) return;\n const btn = rootRef.current?.querySelector<HTMLButtonElement>(\n '[data-cursor=\"true\"]',\n );\n btn?.focus();\n }, [state.cursor]);\n\n const handleKeyDown = useCallback(\n (e: Parameters<NonNullable<CalendarProps[\"onKeyDown\"]>>[0]) => {\n const action = keyToAction(e.key);\n if (action === undefined) return;\n e.preventDefault();\n switch (action) {\n case \"prev\":\n goPrev();\n break;\n case \"next\":\n goNext();\n break;\n default:\n moveCursor(action);\n }\n },\n [moveCursor, goPrev, goNext],\n );\n\n return (\n <Calendar\n ref={rootRef}\n year={state.year}\n month={state.month}\n locale={state.options.locale}\n weekStart={state.options.weekStart}\n highlight={state.options.highlight}\n range={state.options.range}\n today={state.options.today}\n isDateDisabled={isDateDisabled}\n theme={theme}\n colorScheme={colorScheme}\n size={size}\n responsive={responsive}\n style={style}\n interactive\n renderCell={renderCell}\n cellData={cellData}\n selectedDate={hook.selectedDate}\n cursorDate={hook.cursorDate}\n hoveredDate={hook.hoveredDate}\n rangePreview={rangePreview}\n onDateClick={handleDateClick}\n onDateHover={handleDateHover}\n onDateLeave={handleDateLeave}\n onKeyDown={handleKeyDown}\n />\n );\n}\n"],"mappings":";;;;;;;AA2BA,SAAgB,eAAe,MAAY,SAAmC;CAC5E,MAAM,QAAQ,qBAAqB,MAAM,OAAO;CAChD,MAAM,UAAoB,CAAC;CAC3B,IAAI,MAAM,WAAW,QAAQ,KAAK,YAAY;CAC9C,IAAI,MAAM,SAAS,QAAQ,KAAK,UAAU;CAC1C,IAAI,MAAM,aAAa,QAAQ,KAAK,cAAc;CAClD,IAAI,MAAM,WAAW,QAAQ,KAAK,aAAa;CAC/C,IACE,QAAQ,iBAAiB,KAAA,KACzB,cAAc,MAAM,QAAQ,YAAY,GAExC,QAAQ,KAAK,qBAAqB;CACpC,IAAI,MAAM,YAAY,QAAQ,KAAK,aAAa;CAChD,IAAI,QAAQ,eAAe,QAAQ,UAAU,MAAM,QAAQ,WAAW,GACpE,QAAQ,KAAK,YAAY;CAC3B,IAAI,QAAQ,YAAY,QAAQ,UAAU,MAAM,QAAQ,QAAQ,GAC9D,QAAQ,KAAK,aAAa;CAC5B,IAAI,QAAQ,cAAc,QAAQ,UAAU,MAAM,QAAQ,UAAU,GAClE,QAAQ,KAAK,WAAW;CAC1B,OAAO,QAAQ,KAAK,GAAG;AACzB;;;;AC9BA,SAAgBA,iBAAe,MAAmC;CAChE,OAAOC,eAAmB,IAAI;AAChC;;;;AC8EA,SAAgB,SAAS,E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AW;CAG1E,MAAM,gBAAgB,OAAO,MAAM,MAAM;CACzC,gBAAgB;EACd,MAAM,OAAO,cAAc;EAC3B,cAAc,UAAU,MAAM;EAC9B,IAAI,SAAS,MAAM,QAAQ;EAI3B,CAHY,QAAQ,SAAS,cAC3B,wBACF,EAAA,EACK,MAAM;CACb,GAAG,CAAC,MAAM,MAAM,CAAC;CAEjB,MAAM,gBAAgB,aACnB,MAA8D;EAC7D,MAAM,SAAS,YAAY,EAAE,GAAG;EAChC,IAAI,WAAW,KAAA,GAAW;EAC1B,EAAE,eAAe;EACjB,QAAQ,QAAR;GACE,KAAK;IACH,OAAO;IACP;GACF,KAAK;IACH,OAAO;IACP;GACF,SACE,WAAW,MAAM;EACrB;CACF,GACA;EAAC;EAAY;EAAQ;CAAM,CAC7B;CAEA,OACE,oBAAC,UAAD;EACE,KAAK;EACL,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,QAAQ,MAAM,QAAQ;EACtB,WAAW,MAAM,QAAQ;EACzB,WAAW,MAAM,QAAQ;EACzB,OAAO,MAAM,QAAQ;EACrB,OAAO,MAAM,QAAQ;EACL;EACT;EACM;EACP;EACM;EACL;EACP,aAAA;EACY;EACF;EACV,cAAc,KAAK;EACnB,YAAY,KAAK;EACjB,aAAa,KAAK;EACJ;EACd,aAAa;EACb,aAAa;EACb,aAAa;EACb,WAAW;CACZ,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["buildSizeStyle","buildSizeStyleBase","buildSizeStyle","getBlankClasses","joinCellClassLists","getCellStateClasses","getSelectionCellClasses"],"sources":["../src/size.ts","../src/Calendar.tsx","../src/hooks.ts","../src/interactive.tsx"],"sourcesContent":["// ─── セルサイズ ───────────────────────────────────────────\n// サイズ判定・CSS 変数変換は web パッケージに集約済み。\n// ここでは React の style 型(CSSProperties)に適合させる薄いアダプタのみ持つ。\n\nimport type { CalendarSize } from \"@typescript-calendar-lib/web\";\nimport type { CSSProperties } from \"react\";\n\nexport type {\n CalendarCustomSize,\n CalendarSize,\n CalendarSizeName,\n} from \"@typescript-calendar-lib/web\";\nexport { isSizeName } from \"@typescript-calendar-lib/web\";\n\nimport { buildSizeStyle as buildSizeStyleBase } from \"@typescript-calendar-lib/web\";\n\n/** セルサイズを CSS 変数スタイル(--cal-cell-w / --cal-cell-h)へ変換する */\nexport function buildSizeStyle(size: CalendarSize): CSSProperties {\n return buildSizeStyleBase(size) as CSSProperties;\n}\n","import type {\n CalendarCellState,\n CalendarOptions,\n} from \"@typescript-calendar-lib/core\";\nimport {\n addDays,\n buildMonthGrid,\n createDate,\n getCalendarCellState,\n getISOWeek,\n getMonthName,\n getWeekdayHeaders,\n getWeekOfYear,\n isSameDay,\n} from \"@typescript-calendar-lib/core\";\nimport {\n formatCellLabel,\n getBlankClasses,\n getCellStateClasses,\n getSelectionCellClasses,\n joinCellClassLists,\n uiString,\n} from \"@typescript-calendar-lib/web\";\nimport type {\n CSSProperties,\n KeyboardEvent as ReactKeyboardEvent,\n ReactNode,\n Ref,\n} from \"react\";\nimport { useId, useMemo } from \"react\";\nimport type { CalendarSize } from \"./size.ts\";\nimport { buildSizeStyle, isSizeName } from \"./size.ts\";\nimport type {\n ColorSchemeName,\n ReactColorScheme,\n ReactTheme,\n ThemeName,\n} from \"./themes.ts\";\nimport { mergeColorScheme, resolveTheme } from \"./themes.ts\";\n\nexport type {\n CalendarCustomSize,\n CalendarSize,\n CalendarSizeName,\n} from \"./size.ts\";\n\nexport interface CalendarProps {\n year: number;\n month: number;\n locale?: CalendarOptions[\"locale\"];\n holidayLocale?: CalendarOptions[\"holidayLocale\"];\n weekStart?: CalendarOptions[\"weekStart\"];\n /** 各週の先頭に週番号(ISO/年始基準)を表示する。既定は false */\n showWeekNumbers?: boolean;\n highlight?: Date;\n /** 範囲強調 */\n range?: { from: Date; to: Date };\n /** 今日の基準日。カラースキームの today 着色に使用 */\n today?: Date;\n /** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスで視覚化される */\n rangePreview?: { from: Date; to: Date };\n /** 見た目テーマ。既定は \"default\" */\n theme?: ThemeName | ReactTheme;\n /** カラースキーム。既定は \"default\" */\n colorScheme?: ColorSchemeName | ReactColorScheme;\n /** セルサイズ。既定は \"md\"。{ width, height } で自由に指定できる */\n size?: CalendarSize;\n /** 狭い画面(スマホ等)でセルサイズと余白を自動調整する。既定は false(無効) */\n responsive?: boolean;\n /** root 要素に追加するスタイル。CSS変数(--cal-*)で自由に上書きできる */\n style?: CSSProperties;\n\n // ── インタラクション ──\n\n /** インタラクティブモードを有効にする。セルクリック・ホバー・キーボード選択が可能になる */\n interactive?: boolean;\n /** セルクリック時のコールバック。第2引数に該当日のデータ(cellData の戻り値)が渡る */\n onDateClick?: (date: Date, data?: unknown) => void;\n /** セルホバー時のコールバック */\n onDateHover?: (date: Date) => void;\n /** カレンダーからマウスが離れたときのコールバック */\n onDateLeave?: () => void;\n /** キーボード操作。root 要素で発火(矢印キー等を InteractiveCalendar が処理する) */\n onKeyDown?: (event: ReactKeyboardEvent<HTMLDivElement>) => void;\n\n // ── セル状態 ──\n\n /** 選択済み日付。aria-selected・aria-pressed と表示スタイルに使用 */\n selectedDate?: Date | null;\n /** カーソル位置の日付。このセルだけ tabIndex=0(roving tabindex)になる */\n cursorDate?: Date | null;\n /** ホバー中の日付。is-hovered クラスで視覚化される */\n hoveredDate?: Date | null;\n /** セル内容のカスタムレンダリング。interactive 時は button の子として描画される。第4引数に該当日のデータが渡る */\n renderCell?: (\n day: number,\n date: Date,\n state: CalendarCellState,\n data?: unknown,\n ) => ReactNode;\n /** 各セルに付与するユーザー定義データを解決する関数。実セルのみに呼ばれる */\n cellData?: (date: Date) => unknown;\n /** 選択不可日付の判定。true を返した日付は is-disabled クラスになり、インタラクティブ時は選択・ホバーできなくなる */\n isDateDisabled?: (date: Date) => boolean;\n\n /** root 要素への ref(React 19 の ref-as-prop) */\n ref?: Ref<HTMLDivElement>;\n}\n\n/** 月カレンダーコンポーネント */\nexport function Calendar({\n year,\n month,\n locale = \"en\",\n holidayLocale,\n weekStart = \"sunday\",\n showWeekNumbers = false,\n highlight,\n range,\n today,\n theme = \"default\",\n colorScheme = \"default\",\n size = \"md\",\n responsive = false,\n style,\n interactive = false,\n onDateClick,\n onDateHover,\n onDateLeave,\n onKeyDown,\n selectedDate = null,\n cursorDate = null,\n hoveredDate = null,\n renderCell,\n cellData,\n isDateDisabled,\n rangePreview,\n ref,\n}: CalendarProps) {\n // グリッドは月単位で不変。ホバー・選択の再描画でも再計算しない\n const grid = useMemo(\n () => buildMonthGrid(year, month, weekStart),\n [year, month, weekStart],\n );\n\n const handleCellClick = (date: Date, data?: unknown) => {\n if (interactive && onDateClick) onDateClick(date, data);\n };\n\n const handleCellHover = (date: Date) => {\n if (interactive && onDateHover) onDateHover(date);\n };\n\n const handleMouseLeave = () => {\n if (interactive && onDateLeave) onDateLeave();\n };\n\n const title = `${getMonthName(locale, month)} ${year}`;\n // 週番号の行ヘッダー(scope=\"row\")用ラベル。行ごとに一意の名前にするため\n // 番号を含める(aria-label が内容の数字を上書きしないように)\n const weekLabel = uiString(\"weekNumber\", locale);\n const weekOf = (row: (number | null)[]): number | null => {\n const firstIdx = row.findIndex((d) => d !== null);\n if (firstIdx === -1) return null;\n const firstDate = createDate(year, month - 1, row[firstIdx]!);\n const weekStartDate = addDays(firstDate, -firstIdx);\n return weekStart === \"monday\"\n ? getISOWeek(weekStartDate)\n : getWeekOfYear(weekStartDate);\n };\n // インタラクティブ時のみ APG の grid セマンティクスを付与する。\n // 静的表示ではネイティブの table/cell セマンティクスをそのまま使う。\n const gridRole = interactive ? \"grid\" : undefined;\n const cellRole = interactive ? \"gridcell\" : undefined;\n // h2 には一意な id を振り、table は aria-labelledby でそれを参照する。\n // useId() を使うのは同じ月のカレンダーが複数同時に置かれた場合に\n // id が衝突し aria-labelledby が別のカレンダーを見指すため。\n // aria-label と h2 の両方に同じ文字列を置くとスクリーンリーダーが二重に読む。\n const headingId = useId();\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: onMouseLeave はホバー状態クリア用の補助イベント。キーボード操作(role=grid)は独立して対応済み\n <div\n ref={ref}\n className={`calendar ${resolveTheme(theme).className}${isSizeName(size) ? ` calendar-size-${size}` : \"\"}${interactive ? \" calendar-interactive\" : \"\"}${responsive ? \" calendar-responsive\" : \"\"}`}\n onMouseLeave={interactive ? handleMouseLeave : undefined}\n style={{\n ...(mergeColorScheme(colorScheme) as CSSProperties),\n ...buildSizeStyle(size),\n ...style,\n }}\n >\n <div className=\"calendar-header\">\n <h2\n id={headingId}\n aria-live={gridRole ? \"polite\" : undefined}\n aria-atomic={gridRole ? \"true\" : undefined}\n >\n {title}\n </h2>\n </div>\n <table role={gridRole} aria-labelledby={headingId} onKeyDown={onKeyDown}>\n <thead>\n <tr>\n {showWeekNumbers && (\n <th\n key=\"week\"\n className=\"calendar-week\"\n scope=\"col\"\n aria-label={uiString(\"weekNumber\", locale)}\n />\n )}\n {getWeekdayHeaders(locale, weekStart).map((day) => (\n <th key={day} scope=\"col\">\n {day}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {grid.map((row, i) => {\n if (row.every((d) => d === null)) return null;\n const week = weekOf(row);\n return (\n // biome-ignore lint/suspicious/noArrayIndexKey: 月グリッドは静的で並び順が変わらない\n <tr key={i}>\n {showWeekNumbers && week !== null && (\n <th\n key=\"week\"\n className=\"calendar-week\"\n scope=\"row\"\n aria-label={`${weekLabel} ${week}`}\n >\n {week}\n </th>\n )}\n {row.map((day, j) => {\n if (day === null) {\n // biome-ignore-start lint/suspicious/noArrayIndexKey: パディングセルは日付を持たず列位置 j が唯一の識別子。月グリッドは静的で並び順が入れ替わらないため\n return (\n <td\n key={`b-${j}`}\n role={cellRole}\n className={getBlankClasses()}\n />\n );\n // biome-ignore-end lint/suspicious/noArrayIndexKey: 上記と同じ理由\n }\n // 1セルにつき Date・状態・クラスを1回だけ計算する。\n // Date は year/month 固定で day のみ変わるため createDate で正確に作る\n const date = createDate(year, month - 1, day);\n const state = getCalendarCellState(date, {\n today,\n holidayLocale,\n highlight,\n range,\n isDateDisabled,\n });\n const className =\n joinCellClassLists(\n getCellStateClasses(state),\n getSelectionCellClasses(date, {\n rangePreview,\n hoveredDate,\n selected: selectedDate,\n cursorDate,\n }),\n ) || undefined;\n const selected =\n selectedDate !== null && isSameDay(date, selectedDate);\n const cursor =\n cursorDate !== null && isSameDay(date, cursorDate);\n const onClick =\n interactive && !state.isDisabled\n ? () => handleCellClick(date, cellData?.(date))\n : undefined;\n const onEnter =\n interactive && !state.isDisabled\n ? () => handleCellHover(date)\n : undefined;\n return (\n // biome-ignore lint/a11y/useAriaPropsSupportedByRole: interactive 時は td に role=gridcell が付き aria-selected は有効(role が動的なため静的解析できない)\n <td\n // パディングセル(key=j)との衝突を避けるため日番号に \"d-\" を付与する。日番号は列位置 j と異なり配列の index ではない\n key={`d-${day}`}\n role={cellRole}\n className={className}\n aria-selected={selected || undefined}\n aria-current={state.isToday ? \"date\" : undefined}\n aria-disabled={state.isDisabled || undefined}\n >\n {interactive ? (\n <button\n type=\"button\"\n className=\"calendar-day-btn\"\n onClick={onClick}\n onMouseEnter={onEnter}\n tabIndex={cursor ? 0 : -1}\n data-cursor={cursor ? \"true\" : undefined}\n aria-label={formatCellLabel(locale, year, month, day)}\n aria-pressed={selected}\n disabled={state.isDisabled}\n >\n {renderCell\n ? renderCell(day, date, state, cellData?.(date))\n : day}\n </button>\n ) : renderCell ? (\n renderCell(day, date, state, cellData?.(date))\n ) : (\n day\n )}\n </td>\n );\n })}\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n}\n\nexport default Calendar;\n","import type { DateRange } from \"@typescript-calendar-lib/core\";\nimport type {\n CalendarState,\n CalendarStateOptions,\n Direction,\n MonthDirection,\n} from \"@typescript-calendar-lib/tui\";\nimport {\n clearSelection,\n createCalendarState,\n getCursorDate,\n getSelectedDate,\n getSelectedRange,\n goToDate,\n goToMonth,\n goToToday,\n moveCursor,\n navigateMonth,\n navigateYear,\n sameStateOptions,\n selectDate,\n selectDateAt,\n selectRange,\n setCursorToDate,\n updateStateOptions,\n} from \"@typescript-calendar-lib/tui\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport interface UseCalendarStateOptions\n extends Pick<\n CalendarStateOptions,\n | \"locale\"\n | \"holidayLocale\"\n | \"weekStart\"\n | \"today\"\n | \"highlight\"\n | \"range\"\n | \"isDateDisabled\"\n | \"selectionMode\"\n > {\n initialYear?: number;\n initialMonth?: number;\n /** 表示中の年月が変わったときに呼ばれる */\n onMonthChange?: (year: number, month: number) => void;\n}\n\nexport interface UseCalendarStateReturn {\n /** 現在のカレンダー状態 */\n state: CalendarState;\n /** カーソルを指定方向に移動 (wrap around) */\n moveCursor: (direction: Direction) => void;\n /** 前月/翌月へ移動 */\n goNext: () => void;\n goPrev: () => void;\n /** 前年/翌年へ移動 */\n navigateYear: (direction: MonthDirection) => void;\n /** 指定した年月へジャンプ */\n goToMonth: (year: number, month: number) => void;\n /** 指定した日付の月へジャンプし、カーソルをその日付に置く */\n goToDate: (date: Date) => void;\n /** 今日の月へジャンプ */\n goToday: () => void;\n /** カーソル位置の日付を選択 */\n selectDate: () => void;\n /** 指定した日付へカーソルを移動する(当月に無ければ何もしない) */\n setCursorToDate: (date: Date) => void;\n /** 指定した日付を選択し、カーソルもそこへ移動する(当月に無ければ何もしない) */\n selectDateAt: (date: Date) => void;\n /** 範囲を直接設定して選択する(from/to は自動で整列される) */\n selectRange: (from: Date, to: Date) => void;\n /** 選択を解除 */\n clearSelection: () => void;\n /** カーソル位置の日付(null の場合あり) */\n cursorDate: Date | null;\n /** 選択済み日付(null の場合あり) */\n selectedDate: Date | null;\n /** 確定した選択範囲(range モードで確定した範囲)。未確定なら null */\n selectedRange: DateRange | null;\n /** ホバー中の日付(null の場合あり) */\n hoveredDate: Date | null;\n /** ホバー日付を更新する */\n setHoveredDate: (date: Date | null) => void;\n}\n\n/**\n * tui の不変状態マシンを包む React hook。\n * カレンダーのインタラクティブ操作をシンプルに利用できる。\n *\n * `options` の値(locale / weekStart / today / highlight / range / selectionMode /\n * initialYear / initialMonth)が変わると、カーソル・選択を保ったまま\n * 状態が再構築される。比較は値(Date は getTime)で行うため、インラインで\n * オプションを渡しても値が同じなら再構築されない。\n *\n * `today` を省略した場合、最初に解決された値が状態に固定され、以降も\n * 引き継がれる(毎レンダリング `new Date()` を渡さなくてよい)。\n */\nexport function useCalendarState(\n options: UseCalendarStateOptions = {},\n): UseCalendarStateReturn {\n const [state, setState] = useState<CalendarState>(() =>\n createCalendarState(options),\n );\n\n // ホバー中の日付は React ローカル state で保持する(tui 状態には入れない)。\n const [hoveredDate, setHoveredDate] = useState<Date | null>(null);\n\n // options の「値の変化」を検知して状態を再構築する。\n // 初回は prevOptions が同一なので何もしない。値が同じままの再レンダリング\n // でも何もしないため、インラインリテラルを毎回渡しても無限ループしない。\n const prevOptions = useRef(options);\n useEffect(() => {\n if (sameStateOptions(prevOptions.current, options)) return;\n const previous = prevOptions.current;\n prevOptions.current = options;\n setState((current) => updateStateOptions(current, options, previous));\n }, [options]);\n\n // onMonthChange: ref 経由で安定参照\n const onMonthChangeRef = useRef(options.onMonthChange);\n onMonthChangeRef.current = options.onMonthChange;\n\n // 表示月が変わったら onMonthChange を通知し、古い月を指すホバーをクリアする\n const prevMonthRef = useRef({ year: state.year, month: state.month });\n useEffect(() => {\n const prev = prevMonthRef.current;\n if (prev.year !== state.year || prev.month !== state.month) {\n prevMonthRef.current = { year: state.year, month: state.month };\n onMonthChangeRef.current?.(state.year, state.month);\n setHoveredDate(null);\n }\n }, [state.year, state.month]);\n\n return {\n state,\n moveCursor: useCallback(\n (direction: Direction) => setState((prev) => moveCursor(prev, direction)),\n [],\n ),\n goNext: useCallback(\n () => setState((prev) => navigateMonth(prev, \"next\")),\n [],\n ),\n goPrev: useCallback(\n () => setState((prev) => navigateMonth(prev, \"prev\")),\n [],\n ),\n navigateYear: useCallback(\n (direction: MonthDirection) =>\n setState((prev) => navigateYear(prev, direction)),\n [],\n ),\n goToMonth: useCallback(\n (year: number, month: number) =>\n setState((prev) => goToMonth(prev, year, month)),\n [],\n ),\n goToDate: useCallback(\n (date: Date) => setState((prev) => goToDate(prev, date)),\n [],\n ),\n goToday: useCallback(() => setState((prev) => goToToday(prev)), []),\n selectDate: useCallback(() => setState((prev) => selectDate(prev)), []),\n setCursorToDate: useCallback(\n (date: Date) => setState((prev) => setCursorToDate(prev, date)),\n [],\n ),\n selectDateAt: useCallback(\n (date: Date) => setState((prev) => selectDateAt(prev, date)),\n [],\n ),\n selectRange: useCallback(\n (from: Date, to: Date) => setState((prev) => selectRange(prev, from, to)),\n [],\n ),\n clearSelection: useCallback(\n () => setState((prev) => clearSelection(prev)),\n [],\n ),\n cursorDate: getCursorDate(state),\n selectedDate: getSelectedDate(state),\n selectedRange: getSelectedRange(state),\n hoveredDate,\n setHoveredDate,\n };\n}\n\nexport type { Direction, MonthDirection };\n","import type { CalendarOptions } from \"@typescript-calendar-lib/core\";\nimport type { SelectionMode } from \"@typescript-calendar-lib/tui\";\nimport { keyToAction } from \"@typescript-calendar-lib/tui\";\nimport type { CSSProperties } from \"react\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { Calendar, type CalendarProps } from \"./Calendar.tsx\";\nimport { useCalendarState } from \"./hooks.ts\";\nimport { buildRangePreview } from \"./range-preview.ts\";\nimport type { CalendarSize } from \"./size.ts\";\nimport type {\n ColorSchemeName,\n ReactColorScheme,\n ReactTheme,\n ThemeName,\n} from \"./themes.ts\";\n\nexport interface InteractiveCalendarProps {\n // ── useCalendarState オプション ──\n\n /** 表示開始年。既定は today の年 */\n initialYear?: number;\n /** 表示開始月 (1-12)。範囲外は正規化される */\n initialMonth?: number;\n locale?: CalendarOptions[\"locale\"];\n holidayLocale?: CalendarOptions[\"holidayLocale\"];\n weekStart?: CalendarOptions[\"weekStart\"];\n /** 各週の先頭に週番号(ISO/年始基準)を表示する */\n showWeekNumbers?: boolean;\n /** 選択方式。既定は \"single\"。範囲選択時はクリックのたびにアンカー→確定→リセットを交互に行う */\n selectionMode?: SelectionMode;\n /** ハイライト対象日 */\n highlight?: Date;\n /** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスで視覚化される */\n range?: { from: Date; to: Date };\n /** 今日の基準日。省略時は初回レンダリング時刻に解決される */\n today?: Date;\n /** 選択不可日付の判定。true を返した日付は選択・カーソル移動・ホバーの対象外になる */\n isDateDisabled?: (date: Date) => boolean;\n /** 表示中の年月が変わったときに呼ばれる */\n onMonthChange?: (year: number, month: number) => void;\n\n // ── Calendar の見た目 ──\n\n theme?: ThemeName | ReactTheme;\n colorScheme?: ColorSchemeName | ReactColorScheme;\n size?: CalendarSize;\n /** 狭い画面(スマホ等)でセルサイズと余白を自動調整する */\n responsive?: boolean;\n style?: CSSProperties;\n /** セル内容のカスタムレンダリング。第4引数に該当日のデータが渡る */\n renderCell?: CalendarProps[\"renderCell\"];\n /** 各セルに付与するユーザー定義データを解決する関数。実セルのみに呼ばれる */\n cellData?: (date: Date) => unknown;\n\n // ── イベント ──\n\n /** セルクリック時(キーボードの Enter/Space 含む)。クリックした日付は自動的に選択される。第2引数に該当日のデータが渡る */\n onDateClick?: (date: Date, data?: unknown) => void;\n /** セルホバー時 */\n onDateHover?: (date: Date) => void;\n /** カレンダーからマウスが離れたとき */\n onDateLeave?: () => void;\n}\n\n/**\n * `useCalendarState` と `Calendar` を一体化したインタラクティブカレンダー。\n * 内部で状態を管理し、以下の操作に対応する:\n *\n * - マウス: セルクリックで日付を選択(カーソルもそこへ移動) / ホバー追跡 /\n * 選択済み日付とホバー日付の間を範囲プレビュー表示\n * - キーボード: 矢印キー(カーソル移動)・PageUp/PageDown(月移動)・\n * Enter/Space(クリックと同じ日付選択)\n */\nexport function InteractiveCalendar(props: InteractiveCalendarProps) {\n const {\n initialYear,\n initialMonth,\n locale,\n holidayLocale,\n weekStart,\n showWeekNumbers,\n selectionMode,\n highlight,\n range,\n today,\n isDateDisabled,\n onMonthChange,\n theme,\n colorScheme,\n size,\n responsive,\n style,\n renderCell,\n cellData,\n onDateClick,\n onDateHover,\n onDateLeave,\n } = props;\n\n const hook = useCalendarState({\n initialYear,\n initialMonth,\n locale,\n holidayLocale,\n weekStart,\n selectionMode,\n today,\n highlight,\n range,\n isDateDisabled,\n onMonthChange,\n });\n\n const { state, moveCursor, goPrev, goNext, selectDateAt, setHoveredDate } =\n hook;\n const rootRef = useRef<HTMLDivElement>(null);\n\n // クリック(マウス・Enter/Space 共通)で日付を選択する。\n // 従来の onDateClick コールバックも引き続き発火し、第2引数に該当日のデータが渡る。\n const handleDateClick = useCallback(\n (date: Date, data?: unknown) => {\n selectDateAt(date);\n onDateClick?.(date, data);\n },\n [selectDateAt, onDateClick],\n );\n\n const handleDateHover = useCallback(\n (date: Date) => {\n setHoveredDate(date);\n onDateHover?.(date);\n },\n [setHoveredDate, onDateHover],\n );\n\n const handleDateLeave = useCallback(() => {\n setHoveredDate(null);\n onDateLeave?.();\n }, [setHoveredDate, onDateLeave]);\n\n // 確定済みの選択範囲は、次のピックが始まるまでプレビューとして表示し続ける。\n // 未確定なら選択済み日付とホバー日付の間を範囲プレビューとして表示する。\n const rangePreview =\n hook.selectedRange ??\n buildRangePreview(hook.selectedDate, hook.hoveredDate);\n\n // カーソルが動いたときだけ、そのセルへフォーカスを移す(初回マウントでは動かさない)\n const prevCursorRef = useRef(state.cursor);\n useEffect(() => {\n const prev = prevCursorRef.current;\n prevCursorRef.current = state.cursor;\n if (prev === state.cursor) return;\n const btn = rootRef.current?.querySelector<HTMLButtonElement>(\n '[data-cursor=\"true\"]',\n );\n btn?.focus();\n }, [state.cursor]);\n\n const handleKeyDown = useCallback(\n (e: Parameters<NonNullable<CalendarProps[\"onKeyDown\"]>>[0]) => {\n const action = keyToAction(e.key);\n if (action === undefined) return;\n e.preventDefault();\n switch (action) {\n case \"prev\":\n goPrev();\n break;\n case \"next\":\n goNext();\n break;\n default:\n moveCursor(action);\n }\n },\n [moveCursor, goPrev, goNext],\n );\n\n return (\n <Calendar\n ref={rootRef}\n year={state.year}\n month={state.month}\n locale={state.options.locale}\n holidayLocale={state.options.holidayLocale}\n weekStart={state.options.weekStart}\n showWeekNumbers={showWeekNumbers}\n highlight={state.options.highlight}\n range={state.options.range}\n today={state.options.today}\n isDateDisabled={isDateDisabled}\n theme={theme}\n colorScheme={colorScheme}\n size={size}\n responsive={responsive}\n style={style}\n interactive\n renderCell={renderCell}\n cellData={cellData}\n selectedDate={hook.selectedDate}\n cursorDate={hook.cursorDate}\n hoveredDate={hook.hoveredDate}\n rangePreview={rangePreview}\n onDateClick={handleDateClick}\n onDateHover={handleDateHover}\n onDateLeave={handleDateLeave}\n onKeyDown={handleKeyDown}\n />\n );\n}\n"],"mappings":";;;;;;;AAiBA,SAAgBA,iBAAe,MAAmC;CAChE,OAAOC,eAAmB,IAAI;AAChC;;;;AC2FA,SAAgB,SAAS,EACvB,MACA,OACA,SAAS,MACT,eACA,YAAY,UACZ,kBAAkB,OAClB,WACA,OACA,OACA,QAAQ,WACR,cAAc,WACd,OAAO,MACP,aAAa,OACb,OACA,cAAc,OACd,aACA,aACA,aACA,WACA,eAAe,MACf,aAAa,MACb,cAAc,MACd,YACA,UACA,gBACA,cACA,OACgB;CAEhB,MAAM,OAAO,cACL,eAAe,MAAM,OAAO,SAAS,GAC3C;EAAC;EAAM;EAAO;CAAS,CACzB;CAEA,MAAM,mBAAmB,MAAY,SAAmB;EACtD,IAAI,eAAe,aAAa,YAAY,MAAM,IAAI;CACxD;CAEA,MAAM,mBAAmB,SAAe;EACtC,IAAI,eAAe,aAAa,YAAY,IAAI;CAClD;CAEA,MAAM,yBAAyB;EAC7B,IAAI,eAAe,aAAa,YAAY;CAC9C;CAEA,MAAM,QAAQ,GAAG,aAAa,QAAQ,KAAK,EAAE,GAAG;CAGhD,MAAM,YAAY,SAAS,cAAc,MAAM;CAC/C,MAAM,UAAU,QAA0C;EACxD,MAAM,WAAW,IAAI,WAAW,MAAM,MAAM,IAAI;EACh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
4
|
"description": "React 19 calendar components with CSS themes and color schemes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -28,13 +28,14 @@
|
|
|
28
28
|
],
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@typescript-calendar-lib/core": "0.5.
|
|
32
|
-
"@typescript-calendar-lib/tui": "0.5.
|
|
33
|
-
"@typescript-calendar-lib/web": "0.5.
|
|
31
|
+
"@typescript-calendar-lib/core": "^0.5.4",
|
|
32
|
+
"@typescript-calendar-lib/tui": "^0.5.4",
|
|
33
|
+
"@typescript-calendar-lib/web": "^0.5.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@testing-library/react": "^16",
|
|
37
37
|
"@types/react": "^19",
|
|
38
|
+
"@types/react-dom": "^19.3.0",
|
|
38
39
|
"jsdom": "^30",
|
|
39
40
|
"react": "19.3.0",
|
|
40
41
|
"react-dom": "19.3.0",
|