@typescript-calendar-lib/react 0.6.1 → 0.6.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @typescript-calendar-lib/react
2
2
 
3
- A `<Calendar />` React component with CSS-based themes and color schemes, plus a `useCalendarState` hook for full interactivity. The component is fully controlled — you pass `year` and `month` and it renders the grid.
3
+ A `<Calendar />` React component with CSS-based themes and color schemes, plus a `useCalendarState` hook for full interactivity. The component is fully controlled — you pass `year` + `month` (or a single `date`) and it renders the grid.
4
4
 
5
5
  > **Warning: Peer dependency** — Requires React 19. The package doesn't bundle React; install it in your app:
6
6
  >
@@ -25,14 +25,7 @@ import { Calendar } from "@typescript-calendar-lib/react";
25
25
  import "@typescript-calendar-lib/react/calendar.css"; // required — component styles
26
26
 
27
27
  export function App() {
28
- return (
29
- <Calendar
30
- year={2026}
31
- month={9}
32
- colorScheme="ocean"
33
- theme="modern"
34
- />
35
- );
28
+ return <Calendar year={2026} month={9} colorScheme="ocean" theme="modern" />;
36
29
  }
37
30
  ```
38
31
 
@@ -78,37 +71,39 @@ export function CalendarPanel() {
78
71
  ### `Calendar`
79
72
 
80
73
  ```tsx
81
- <Calendar year={2026} month={9} />
74
+ <Calendar year={2026} month={9} />;
82
75
  ```
83
76
 
84
- | Prop | Type | Default | Description |
85
- | :--- | :--- | :--- | :--- |
86
- | `year` | `number` | — (required) | Calendar year |
87
- | `month` | `number` | — (required) | Month, 1-indexed (`1`–`12`) |
88
- | `locale` | `"en" \| "ja" \| "es" \| "de" \| "fr" \| "ko" \| "zh"` | `"en"` | Language |
89
- | `holidayLocale` | `"en" \| "ja" \| "es" \| "de" \| "fr" \| "ko" \| "zh"` | `"ja"` | Holiday rules (fixed-date holidays for every locale; moving holidays such as Easter are not included) |
90
- | `weekStart` | `"sunday" \| "monday"` | `"sunday"` | First day of the week |
91
- | `highlight` | `Date` | — | Date to highlight |
92
- | `range` | `{ from: Date; to: Date }` | — | Dates to emphasize |
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) |
95
- | `today` | `Date` | — | Reference date for "today" styling |
96
- | `theme` | `ThemeName \| ReactTheme` | `"default"` | CSS class-based theme |
97
- | `colorScheme` | `ColorSchemeName \| ReactColorScheme` | `"default"` | CSS variable-based colors |
98
- | `size` | `CalendarSize` | `"md"` | Cell size |
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) |
101
- | `style` | `CSSProperties` | — | Extra styles for the root element |
102
- | `interactive` | `boolean` | `false` | Enable cell click/hover/keyboard selection |
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) |
104
- | `onDateHover` | `(date: Date) => void` | — | Called when a day cell is hovered |
105
- | `onDateLeave` | `() => void` | — | Called when the mouse leaves the calendar |
106
- | `onKeyDown` | `(e: KeyboardEvent) => void` | — | Keyboard handler on the grid element |
107
- | `selectedDate` | `Date \| null` | `null` | Marks the gridcell `aria-selected` and its interactive button `aria-pressed` |
108
- | `cursorDate` | `Date \| null` | `null` | The cell that gets `tabIndex=0` (roving tabindex) |
109
- | `hoveredDate` | `Date \| null` | `null` | Marks the hovered cell with the `is-hovered` class |
110
- | `cellData` | `(date: Date) => unknown` | — | Resolve per-cell data; passed to `renderCell` and `onDateClick` |
111
- | `renderCell` | `(day, date, state, data?) => ReactNode` | — | Custom cell content renderer |
77
+ | Prop | Type | Default | Description |
78
+ | :---------------- | :----------------------------------------------------- | :---------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
79
+ | `date` | `Date` | — | Shorthand for `year` + `month`; takes precedence when both are given |
80
+ | `year` | `number` | — | Calendar year (required unless `date` is given) |
81
+ | `month` | `number` | — | Month, 1-indexed (`1`–`12`) (required unless `date` is given) |
82
+ | `locale` | `"en" \| "ja" \| "es" \| "de" \| "fr" \| "ko" \| "zh"` | `"en"` | Language |
83
+ | `holidayLocale` | `"en" \| "ja" \| "es" \| "de" \| "fr" \| "ko" \| "zh"` | `"ja"` | Holiday rules (fixed-date holidays for every locale; moving holidays such as Easter are not included) |
84
+ | `weekStart` | `"sunday" \| "monday"` | `"sunday"` | First day of the week |
85
+ | `highlight` | `Date` | — | Date to highlight |
86
+ | `range` | `{ from: Date; to: Date }` | — | Dates to emphasize |
87
+ | `rangePreview` | `{ from: Date; to: Date }` | — | Candidate range preview (hover preview), rendered with the `is-in-range-preview` class |
88
+ | `isDateDisabled` | `(date: Date) => boolean` | — | Mark dates as non-selectable in interactive mode (`is-disabled` class) |
89
+ | `today` | `Date` | — | Reference date for "today" styling |
90
+ | `theme` | `ThemeName \| ReactTheme` | `"default"` | CSS class-based theme |
91
+ | `colorScheme` | `ColorSchemeName \| ReactColorScheme` | `"default"` | CSS variable-based colors |
92
+ | `size` | `CalendarSize` | `"md"` | Cell size |
93
+ | `responsive` | `boolean` | `false` | Shrink cells & padding below `480px` so the grid fits phone screens |
94
+ | `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) |
95
+ | `className` | `string` | — | Extra class on the root element |
96
+ | `style` | `CSSProperties` | — | Extra styles for the root element |
97
+ | `interactive` | `boolean` | `false` | Enable cell click/hover/keyboard selection |
98
+ | `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) |
99
+ | `onDateHover` | `(date: Date) => void` | — | Called when a day cell is hovered |
100
+ | `onDateLeave` | `() => void` | — | Called when the mouse leaves the calendar |
101
+ | `onKeyDown` | `(e: KeyboardEvent) => void` | — | Keyboard handler on the grid element |
102
+ | `selectedDate` | `Date \| null` | `null` | Marks the gridcell `aria-selected` and its interactive button `aria-pressed` |
103
+ | `cursorDate` | `Date \| null` | `null` | The cell that gets `tabIndex=0` (roving tabindex) |
104
+ | `hoveredDate` | `Date \| null` | `null` | Marks the hovered cell with the `is-hovered` class |
105
+ | `cellData` | `(date: Date) => unknown` | — | Resolve per-cell data; passed to `renderCell` and `onDateClick` |
106
+ | `renderCell` | `(day, date, state, data?) => ReactNode` | — | Custom cell content renderer |
112
107
 
113
108
  The component exports as both named `Calendar` and default.
114
109
 
@@ -123,7 +118,7 @@ Set `interactive` to make day cells clickable. Each cell becomes a `<button clas
123
118
  interactive
124
119
  onDateClick={(date) => console.log("Selected", date)}
125
120
  onDateHover={(date) => console.log("Hovered", date)}
126
- />
121
+ />;
127
122
  ```
128
123
 
129
124
  `onDateClick` / `onDateHover` notify the caller but don't touch internal state. To select on click, either use `useCalendarState`'s `selectDateAt(date)` (see below) or the ready-made [`InteractiveCalendar`](#interactivecalendar), which wires click-to-select, hover tracking, and range preview out of the box.
@@ -138,23 +133,23 @@ import "@typescript-calendar-lib/react/calendar.css"; // required — component
138
133
 
139
134
  function App() {
140
135
  const {
141
- state, // CalendarState (tui)
142
- goNext, // () => void — next month
143
- goPrev, // () => void — previous month
144
- goToday, // () => void — jump to today
136
+ state, // CalendarState (tui)
137
+ goNext, // () => void — next month
138
+ goPrev, // () => void — previous month
139
+ goToday, // () => void — jump to today
145
140
  navigateYear, // (direction) => void — "prev" | "next" year
146
- goToMonth, // (year, month) => void — jump to a specific month
147
- goToDate, // (date) => void — jump to a date's month, cursor on that date
148
- moveCursor, // (direction) => void — "up" | "down" | "left" | "right"
149
- selectDate, // () => void — select date under cursor
141
+ goToMonth, // (year, month) => void — jump to a specific month
142
+ goToDate, // (date) => void — jump to a date's month, cursor on that date
143
+ moveCursor, // (direction) => void — "up" | "down" | "left" | "right"
144
+ selectDate, // () => void — select date under cursor
150
145
  setCursorToDate, // (date) => void — move cursor to a date (same month only)
151
146
  selectDateAt, // (date) => void — move cursor to a date and select it
152
- selectRange, // (from, to) => void — set a committed range (range mode)
147
+ selectRange, // (from, to) => void — set a committed range (range mode)
153
148
  clearSelection,
154
- cursorDate, // Date | null
149
+ cursorDate, // Date | null
155
150
  selectedDate, // Date | null
156
151
  selectedRange, // DateRange | null — committed range (range mode)
157
- hoveredDate, // Date | null
152
+ hoveredDate, // Date | null
158
153
  setHoveredDate, // (date | null) => void
159
154
  } = useCalendarState({
160
155
  initialYear: 2026,
@@ -168,7 +163,7 @@ function App() {
168
163
  year={state.year}
169
164
  month={state.month}
170
165
  interactive
171
- onDateClick={selectDateAt} // click a cell → select it
166
+ onDateClick={selectDateAt} // click a cell → select it
172
167
  onDateHover={setHoveredDate} // track the hovered cell
173
168
  />
174
169
  <button onClick={goNext}>›</button>
@@ -183,16 +178,16 @@ function App() {
183
178
 
184
179
  `InteractiveCalendar` bundles `useCalendarState` + `<Calendar>` into a single self-contained component. It manages its own state and supports mouse and keyboard interaction out of the box:
185
180
 
186
- | Input | Action |
187
- | :--- | :--- |
188
- | Click a cell | Selects the date (cursor moves there); fires `onDateClick` |
189
- | Hover a cell | Tracks the hovered date (adds `is-hovered` class); fires `onDateHover` |
190
- | Mouse leaves | Clears the hover state; fires `onDateLeave` |
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"`) |
193
- | Arrow keys | Move the cursor (focus follows the cursor cell) |
194
- | `PageUp` / `PageDown` | Previous / next month |
195
- | Enter / Space | Same as clicking the focused cell (selects it) |
181
+ | Input | Action |
182
+ | :-------------------- | :------------------------------------------------------------------------------------------------- |
183
+ | Click a cell | Selects the date (cursor moves there); fires `onDateClick` |
184
+ | Hover a cell | Tracks the hovered date (adds `is-hovered` class); fires `onDateHover` |
185
+ | Mouse leaves | Clears the hover state; fires `onDateLeave` |
186
+ | Selection + hover | Shows a range preview between the selected date and the hovered date (`is-in-range-preview` class) |
187
+ | Picking (range mode) | Alternates anchor → committed range → new anchor (`selectionMode="range"`) |
188
+ | Arrow keys | Move the cursor (focus follows the cursor cell) |
189
+ | `PageUp` / `PageDown` | Previous / next month |
190
+ | Enter / Space | Same as clicking the focused cell (selects it) |
196
191
 
197
192
  ```tsx
198
193
  import { InteractiveCalendar } from "@typescript-calendar-lib/react";
@@ -213,7 +208,7 @@ function App() {
213
208
  }
214
209
  ```
215
210
 
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`).
211
+ It accepts the `useCalendarState` options (`initialYear`, `initialMonth`, `initialDate`, `locale`, `holidayLocale`, `weekStart`, `selectionMode`, `highlight`, `range`, `today`, `isDateDisabled`, `onMonthChange`) plus the `Calendar` visual props (`theme`, `colorScheme`, `size`, `responsive`, `className`, `style`, `cellData`, `renderCell`) and event callbacks (`onDateClick`, `onDateHover`, `onDateLeave`).
217
212
 
218
213
  ### Disabled Dates
219
214
 
@@ -224,7 +219,7 @@ Pass `isDateDisabled` to mark dates as non-selectable. Disabled cells get the `i
224
219
  initialYear={2026}
225
220
  initialMonth={9}
226
221
  isDateDisabled={(date) => date.getDay() === 0} // disable Sundays
227
- />
222
+ />;
228
223
  ```
229
224
 
230
225
  ## Range selection
@@ -236,7 +231,7 @@ Pass `selectionMode="range"` to select a date range by clicking. Selection alter
236
231
  initialYear={2026}
237
232
  initialMonth={9}
238
233
  selectionMode="range"
239
- />
234
+ />;
240
235
  ```
241
236
 
242
237
  With the raw hook, use `selectRange(from, to)` to set the range explicitly and read it back from the `selectedRange` return value:
@@ -268,7 +263,7 @@ import type { CalendarCellState } from "@typescript-calendar-lib/core";
268
263
  {state.isInRange && "•"}
269
264
  </span>
270
265
  )}
271
- />
266
+ />;
272
267
  ```
273
268
 
274
269
  `cellData` is called once per real day cell (never for empty cells) and receives the cell's full `Date`; returning `undefined` means "no data". Use it to attach anything — strings, objects, IDs — and consume it in `renderCell` (4th argument) or `onDateClick` (2nd argument):
@@ -280,7 +275,7 @@ import type { CalendarCellState } from "@typescript-calendar-lib/core";
280
275
  interactive
281
276
  cellData={(date) => (date.getDate() === 15 ? "meeting" : undefined)}
282
277
  onDateClick={(date, data) => console.log(date, data)} // data: "meeting" | undefined
283
- />
278
+ />;
284
279
  ```
285
280
 
286
281
  `cellData`/`renderCell` are render-layer options — they are **not** part of `useCalendarState` (`Calendar` re-renders from its props, so hook-level cell data would have no visible effect).
@@ -329,8 +324,13 @@ Predefined theme map and resolver.
329
324
 
330
325
  ```ts
331
326
  type ColorSchemeName =
332
- | "default" | "ocean" | "forest" | "sunset"
333
- | "mono" | "midnight" | "blossom";
327
+ | "default"
328
+ | "ocean"
329
+ | "forest"
330
+ | "sunset"
331
+ | "mono"
332
+ | "midnight"
333
+ | "blossom";
334
334
  ```
335
335
 
336
336
  ### `ReactColorScheme`
@@ -343,24 +343,24 @@ type ReactColorScheme = Record<`--cal-${string}`, string>;
343
343
 
344
344
  Available variables:
345
345
 
346
- | Variable | Purpose |
347
- | :--- | :--- |
348
- | `--cal-bg` | Background |
349
- | `--cal-fg` | Foreground |
350
- | `--cal-accent` | Accent (highlight) |
351
- | `--cal-weekend-fg` | Weekend foreground |
352
- | `--cal-holiday-fg` | Holiday foreground |
353
- | `--cal-border` | Borders |
354
- | `--cal-header-bg` | Header background |
355
- | `--cal-highlight-bg` | Highlight background |
356
- | `--cal-highlight-fg` | Highlight foreground |
357
- | `--cal-range-bg` | Range background |
346
+ | Variable | Purpose |
347
+ | :----------------------- | :-------------------------------------------------------- |
348
+ | `--cal-bg` | Background |
349
+ | `--cal-fg` | Foreground |
350
+ | `--cal-accent` | Accent (highlight) |
351
+ | `--cal-weekend-fg` | Weekend foreground |
352
+ | `--cal-holiday-fg` | Holiday foreground |
353
+ | `--cal-border` | Borders |
354
+ | `--cal-header-bg` | Header background |
355
+ | `--cal-highlight-bg` | Highlight background |
356
+ | `--cal-highlight-fg` | Highlight foreground |
357
+ | `--cal-range-bg` | Range background |
358
358
  | `--cal-range-preview-bg` | Range preview background (falls back to `--cal-range-bg`) |
359
- | `--cal-today-bg` | Today background |
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 |
359
+ | `--cal-today-bg` | Today background |
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
364
 
365
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.
366
366
 
@@ -395,17 +395,13 @@ type CalendarSize = CalendarSizeName | CalendarCustomSize;
395
395
  Use preset sizes (`"sm" | "md" | "lg"`):
396
396
 
397
397
  ```tsx
398
- <Calendar year={2026} month={9} size="lg" />
398
+ <Calendar year={2026} month={9} size="lg" />;
399
399
  ```
400
400
 
401
401
  Or custom pixel sizes:
402
402
 
403
403
  ```tsx
404
- <Calendar
405
- year={2026}
406
- month={9}
407
- size={{ width: 48, height: 40 }}
408
- />
404
+ <Calendar year={2026} month={9} size={{ width: 48, height: 40 }} />;
409
405
  ```
410
406
 
411
407
  Numbers are treated as pixels; strings pass through as CSS lengths (`"3rem"`, `"2.5em"`, etc.).
@@ -415,7 +411,7 @@ Numbers are treated as pixels; strings pass through as CSS lengths (`"3rem"`, `"
415
411
  The 7-column grid has fixed cell sizes, so on narrow phone screens it can overflow. Pass `responsive` to make the calendar shrink its cells, fonts, and padding below `480px` (and a step tighter below `360px`) and fill the viewport width:
416
412
 
417
413
  ```tsx
418
- <Calendar year={2026} month={9} responsive />
414
+ <Calendar year={2026} month={9} responsive />;
419
415
  ```
420
416
 
421
417
  It's **off by default** to keep existing layouts unchanged. The calendar root gets a `calendar-responsive` class that drives CSS media queries — you can also add that class yourself, or use the `style` prop / your own CSS to tune the breakpoints further.
@@ -428,8 +424,10 @@ The `style` prop can override any CSS variable or add custom styles:
428
424
  <Calendar
429
425
  year={2026}
430
426
  month={9}
431
- style={{ "--cal-accent": "#8b5cf6", borderRadius: "1rem" } as React.CSSProperties}
432
- />
427
+ style={
428
+ { "--cal-accent": "#8b5cf6", borderRadius: "1rem" } as React.CSSProperties
429
+ }
430
+ />;
433
431
  ```
434
432
 
435
433
  ## Accessibility notes
@@ -445,16 +443,16 @@ The `style` prop can override any CSS variable or add custom styles:
445
443
 
446
444
  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).
447
445
 
448
- | Class | When |
449
- | :--- | :--- |
450
- | `is-weekend` | Saturday or Sunday |
451
- | `is-holiday` | Holiday per `holidayLocale` (default `"ja"`) |
452
- | `is-today` | Matches `today` |
453
- | `is-highlight` | Matches `highlight` |
454
- | `is-in-range` | Inside `range` |
455
- | `is-in-range-preview` | Inside `rangePreview` |
456
- | `is-hovered` | Matches `hoveredDate` (interactive mode) |
457
- | `is-disabled` | Date returned `true` from `isDateDisabled` (interactive mode) |
446
+ | Class | When |
447
+ | :-------------------- | :------------------------------------------------------------ |
448
+ | `is-weekend` | Saturday or Sunday |
449
+ | `is-holiday` | Holiday per `holidayLocale` (default `"ja"`) |
450
+ | `is-today` | Matches `today` |
451
+ | `is-highlight` | Matches `highlight` |
452
+ | `is-in-range` | Inside `range` |
453
+ | `is-in-range-preview` | Inside `rangePreview` |
454
+ | `is-hovered` | Matches `hoveredDate` (interactive mode) |
455
+ | `is-disabled` | Date returned `true` from `isDateDisabled` (interactive mode) |
458
456
 
459
457
  ## Exports
460
458
 
@@ -493,4 +491,4 @@ import type {
493
491
 
494
492
  ## License
495
493
 
496
- MIT
494
+ MIT
package/dist/index.d.ts CHANGED
@@ -10,8 +10,15 @@ type ReactColorScheme = WebColorScheme;
10
10
  //#endregion
11
11
  //#region src/Calendar.d.ts
12
12
  interface CalendarProps {
13
- year: number;
14
- month: number;
13
+ /**
14
+ * 表示する年月を `Date` で指定する。`year` / `month` の代わりに使える
15
+ * (両方を併用した場合は `date` を優先する)。
16
+ */
17
+ date?: Date;
18
+ /** 表示する年。`date` 省略時は `month` と併せて必須 */
19
+ year?: number;
20
+ /** 表示する月 (1–12)。`date` 省略時は `year` と併せて必須 */
21
+ month?: number;
15
22
  locale?: CalendarOptions["locale"];
16
23
  holidayLocale?: CalendarOptions["holidayLocale"];
17
24
  weekStart?: CalendarOptions["weekStart"];
@@ -38,6 +45,8 @@ interface CalendarProps {
38
45
  size?: CalendarSize;
39
46
  /** 狭い画面(スマホ等)でセルサイズと余白を自動調整する。既定は false(無効) */
40
47
  responsive?: boolean;
48
+ /** root 要素に追加するクラス。レイアウトや追加スタイルのフックに使う */
49
+ className?: string;
41
50
  /** root 要素に追加するスタイル。CSS変数(--cal-*)で自由に上書きできる */
42
51
  style?: CSSProperties;
43
52
  /** インタラクティブモードを有効にする。セルクリック・ホバー・キーボード選択が可能になる */
@@ -66,7 +75,7 @@ interface CalendarProps {
66
75
  ref?: Ref<HTMLDivElement>;
67
76
  }
68
77
  /** 月カレンダーコンポーネント */
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;
78
+ export declare function Calendar({ date: dateProp, year, month, locale, holidayLocale, weekStart, showWeekNumbers, highlight, range, today, theme, colorScheme, size, responsive, className, style, interactive, onDateClick, onDateHover, onDateLeave, onKeyDown, selectedDate, cursorDate, hoveredDate, renderCell, cellData, isDateDisabled, rangePreview, ref }: CalendarProps): import("react").JSX.Element;
70
79
  //#endregion
71
80
  //#region src/hooks.d.ts
72
81
  interface UseCalendarStateOptions extends Pick<CalendarStateOptions, "locale" | "holidayLocale" | "weekStart" | "today" | "highlight" | "range" | "isDateDisabled" | "selectionMode"> {
@@ -139,6 +148,11 @@ interface InteractiveCalendarProps {
139
148
  initialYear?: number;
140
149
  /** 表示開始月 (1-12)。範囲外は正規化される */
141
150
  initialMonth?: number;
151
+ /**
152
+ * 表示開始位置を `Date` で指定する。`initialYear` / `initialMonth` を
153
+ * 個別に指定した場合はそちらが優先される。
154
+ */
155
+ initialDate?: Date;
142
156
  /** 制御モードの表示年。指定すると initialYear より優先され、月移動は onMonthChange に委譲される */
143
157
  year?: number;
144
158
  /** 制御モードの表示月 (1-12) */
@@ -168,6 +182,8 @@ interface InteractiveCalendarProps {
168
182
  size?: CalendarSize;
169
183
  /** 狭い画面(スマホ等)でセルサイズと余白を自動調整する */
170
184
  responsive?: boolean;
185
+ /** root 要素に追加するクラス。レイアウトや追加スタイルのフックに使う */
186
+ className?: string;
171
187
  style?: CSSProperties;
172
188
  /** セル内容のカスタムレンダリング。第4引数に該当日のデータが渡る */
173
189
  renderCell?: CalendarProps["renderCell"];
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
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, lastDayOfMonth, sortRange as buildRangePreview } from "@typescript-calendar-lib/core";
2
+ import { addDays, buildMonthGrid, createDate, getCalendarCellState, getISOWeek, getMonthName, getWeekOfYear, getWeekdayHeaders, getYearMonth, isSameDay, lastDayOfMonth, sortRange as buildRangePreview } from "@typescript-calendar-lib/core";
3
3
  import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
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";
@@ -11,10 +11,16 @@ function buildSizeStyle$1(size) {
11
11
  //#endregion
12
12
  //#region src/Calendar.tsx
13
13
  /** 月カレンダーコンポーネント */
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), [
14
+ function Calendar({ date: dateProp, year, month, locale = "en", holidayLocale, weekStart = "sunday", showWeekNumbers = false, highlight, range, today, theme = "default", colorScheme = "default", size = "md", responsive = false, className, style, interactive = false, onDateClick, onDateHover, onDateLeave, onKeyDown, selectedDate = null, cursorDate = null, hoveredDate = null, renderCell, cellData, isDateDisabled, rangePreview, ref }) {
15
+ const yearMonth = dateProp !== void 0 ? getYearMonth(dateProp) : year !== void 0 && month !== void 0 ? {
16
16
  year,
17
- month,
17
+ month
18
+ } : null;
19
+ if (yearMonth === null) throw new TypeError("Calendar requires either `date` or both `year` and `month`.");
20
+ const { year: displayYear, month: displayMonth } = yearMonth;
21
+ const grid = useMemo(() => buildMonthGrid(displayYear, displayMonth, weekStart), [
22
+ displayYear,
23
+ displayMonth,
18
24
  weekStart
19
25
  ]);
20
26
  const handleCellClick = (date, data) => {
@@ -26,12 +32,12 @@ function Calendar({ year, month, locale = "en", holidayLocale, weekStart = "sund
26
32
  const handleMouseLeave = () => {
27
33
  if (interactive && onDateLeave) onDateLeave();
28
34
  };
29
- const title = `${getMonthName(locale, month)} ${year}`;
35
+ const title = `${getMonthName(locale, displayMonth)} ${displayYear}`;
30
36
  const weekLabel = uiString("weekNumber", locale);
31
37
  const weekOf = (row) => {
32
38
  const firstIdx = row.findIndex((d) => d !== null);
33
39
  if (firstIdx === -1) return null;
34
- const firstDate = createDate(year, month - 1, row[firstIdx]);
40
+ const firstDate = createDate(displayYear, displayMonth - 1, row[firstIdx]);
35
41
  const weekStartDate = addDays(firstDate, -firstIdx);
36
42
  return weekStart === "monday" ? getISOWeek(weekStartDate) : getWeekOfYear(weekStartDate);
37
43
  };
@@ -40,7 +46,7 @@ function Calendar({ year, month, locale = "en", holidayLocale, weekStart = "sund
40
46
  const headingId = useId();
41
47
  return /* @__PURE__ */ jsxs("div", {
42
48
  ref,
43
- className: `calendar ${resolveTheme(theme).className}${isSizeName(size) ? ` calendar-size-${size}` : ""}${interactive ? " calendar-interactive" : ""}${responsive ? " calendar-responsive" : ""}`,
49
+ className: `calendar ${resolveTheme(theme).className}${isSizeName(size) ? ` calendar-size-${size}` : ""}${interactive ? " calendar-interactive" : ""}${responsive ? " calendar-responsive" : ""}${className ? ` ${className}` : ""}`,
44
50
  onMouseLeave: interactive ? handleMouseLeave : void 0,
45
51
  style: {
46
52
  ...mergeColorScheme(colorScheme),
@@ -79,7 +85,7 @@ function Calendar({ year, month, locale = "en", holidayLocale, weekStart = "sund
79
85
  role: cellRole,
80
86
  className: getBlankClasses$1()
81
87
  }, `b-${j}`);
82
- const date = createDate(year, month - 1, day);
88
+ const date = createDate(displayYear, displayMonth - 1, day);
83
89
  const state = getCalendarCellState(date, {
84
90
  today,
85
91
  holidayLocale,
@@ -110,7 +116,7 @@ function Calendar({ year, month, locale = "en", holidayLocale, weekStart = "sund
110
116
  onMouseEnter: onEnter,
111
117
  tabIndex: cursor ? 0 : -1,
112
118
  "data-cursor": cursor ? "true" : void 0,
113
- "aria-label": formatCellLabel(locale, year, month, day),
119
+ "aria-label": formatCellLabel(locale, displayYear, displayMonth, day),
114
120
  "aria-pressed": selected,
115
121
  disabled: state.isDisabled,
116
122
  children: renderCell ? renderCell(day, date, state, cellData?.(date)) : day
@@ -242,10 +248,11 @@ function useCalendarState(options = {}) {
242
248
  * Enter/Space(クリックと同じ日付選択)
243
249
  */
244
250
  function InteractiveCalendar(props) {
245
- const { initialYear, initialMonth, locale, holidayLocale, weekStart, showWeekNumbers, selectionMode, highlight, range, today, isDateDisabled, year, month, onMonthChange, theme, colorScheme, size, responsive, style, renderCell, cellData, onDateClick, onDateHover, onDateLeave } = props;
251
+ const { initialYear, initialMonth, initialDate, locale, holidayLocale, weekStart, showWeekNumbers, selectionMode, highlight, range, today, isDateDisabled, year, month, onMonthChange, theme, colorScheme, size, responsive, className, style, renderCell, cellData, onDateClick, onDateHover, onDateLeave } = props;
252
+ const initialFromDate = initialDate !== void 0 ? getYearMonth(initialDate) : void 0;
246
253
  const hook = useCalendarState({
247
- initialYear,
248
- initialMonth,
254
+ initialYear: initialYear ?? initialFromDate?.year,
255
+ initialMonth: initialMonth ?? initialFromDate?.month,
249
256
  year,
250
257
  month,
251
258
  locale,
@@ -334,6 +341,7 @@ function InteractiveCalendar(props) {
334
341
  colorScheme,
335
342
  size,
336
343
  responsive,
344
+ className,
337
345
  style,
338
346
  interactive: true,
339
347
  renderCell,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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 * 制御モードの表示年。指定すると `initialYear` より優先され、値が変わるたびに\n * その年月へ再構築される。月移動は内部状態を変えず `onMonthChange` に通知する。\n */\n year?: number;\n /** 制御モードの表示月 (1–12)。`year` と併用する */\n month?: 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 // 制御モード(year/month を外部から渡す)かどうか。\n // 制御モードでは月移動は内部状態を変えず onMonthChange に委譲する。\n const controlled = options.year !== undefined || options.month !== undefined;\n const controlledRef = useRef(controlled);\n controlledRef.current = controlled;\n\n // 最新 state を参照するための ref(controlled 分岐で同期的に次月を計算する)\n const stateRef = useRef(state);\n stateRef.current = state;\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 // 制御モードでは props 側が月を決めているので再通知しない(二重通知の抑止)。\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 setHoveredDate(null);\n if (!controlledRef.current) {\n onMonthChangeRef.current?.(state.year, state.month);\n }\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 if (controlledRef.current) {\n const next = navigateMonth(stateRef.current, \"next\");\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => navigateMonth(prev, \"next\"));\n }, []),\n goPrev: useCallback(() => {\n if (controlledRef.current) {\n const next = navigateMonth(stateRef.current, \"prev\");\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => navigateMonth(prev, \"prev\"));\n }, []),\n navigateYear: useCallback((direction: MonthDirection) => {\n if (controlledRef.current) {\n const next = navigateYear(stateRef.current, direction);\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => navigateYear(prev, direction));\n }, []),\n goToMonth: useCallback((year: number, month: number) => {\n if (controlledRef.current) {\n const next = goToMonth(stateRef.current, year, month);\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => goToMonth(prev, year, month));\n }, []),\n goToDate: useCallback((date: Date) => {\n if (controlledRef.current) {\n const next = goToDate(stateRef.current, date);\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => goToDate(prev, date));\n }, []),\n goToday: useCallback(() => {\n if (controlledRef.current) {\n const next = goToToday(stateRef.current);\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => goToToday(prev));\n }, []),\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 { createDate, lastDayOfMonth } 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 /** 制御モードの表示年。指定すると initialYear より優先され、月移動は onMonthChange に委譲される */\n year?: number;\n /** 制御モードの表示月 (1-12) */\n month?: 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 year,\n month,\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 year,\n month,\n locale,\n holidayLocale,\n weekStart,\n selectionMode,\n today,\n highlight,\n range,\n isDateDisabled,\n onMonthChange,\n });\n\n const {\n state,\n moveCursor,\n goPrev,\n goNext,\n navigateYear,\n setCursorToDate,\n clearSelection,\n selectDateAt,\n 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, e);\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 case \"prevYear\":\n navigateYear(\"prev\");\n break;\n case \"nextYear\":\n navigateYear(\"next\");\n break;\n case \"firstDay\":\n setCursorToDate(createDate(state.year, state.month - 1, 1));\n break;\n case \"lastDay\":\n setCursorToDate(lastDayOfMonth(state.year, state.month));\n break;\n case \"clear\":\n clearSelection();\n break;\n default:\n moveCursor(action);\n }\n },\n [\n moveCursor,\n goPrev,\n goNext,\n navigateYear,\n setCursorToDate,\n clearSelection,\n state.year,\n state.month,\n ],\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,aAC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F,GACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;EACN,MAAM;CACR,CACF;CAEA,OACE,oBAAC,UAAD;EACE,KAAK;EACL,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,QAAQ,MAAM,QAAQ;EACtB,eAAe,MAAM,QAAQ;EAC7B,WAAW,MAAM,QAAQ;EACR;EACjB,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 getYearMonth,\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 /**\n * 表示する年月を `Date` で指定する。`year` / `month` の代わりに使える\n * (両方を併用した場合は `date` を優先する)。\n */\n date?: Date;\n /** 表示する年。`date` 省略時は `month` と併せて必須 */\n year?: number;\n /** 表示する月 (1–12)。`date` 省略時は `year` と併せて必須 */\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 要素に追加するクラス。レイアウトや追加スタイルのフックに使う */\n className?: string;\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 date: dateProp,\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 className,\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 // date が指定されればそれを優先し、なければ year/month を使う。\n // どちらも揃っていない場合は、黙って現在月を出さずに即座に失敗させる。\n const yearMonth =\n dateProp !== undefined\n ? getYearMonth(dateProp)\n : year !== undefined && month !== undefined\n ? { year, month }\n : null;\n if (yearMonth === null) {\n throw new TypeError(\n \"Calendar requires either `date` or both `year` and `month`.\",\n );\n }\n const { year: displayYear, month: displayMonth } = yearMonth;\n\n // グリッドは月単位で不変。ホバー・選択の再描画でも再計算しない\n const grid = useMemo(\n () => buildMonthGrid(displayYear, displayMonth, weekStart),\n [displayYear, displayMonth, 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, displayMonth)} ${displayYear}`;\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(displayYear, displayMonth - 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\" : \"\"}${className ? ` ${className}` : \"\"}`}\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(displayYear, displayMonth - 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(\n locale,\n displayYear,\n displayMonth,\n day,\n )}\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 * 制御モードの表示年。指定すると `initialYear` より優先され、値が変わるたびに\n * その年月へ再構築される。月移動は内部状態を変えず `onMonthChange` に通知する。\n */\n year?: number;\n /** 制御モードの表示月 (1–12)。`year` と併用する */\n month?: 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 // 制御モード(year/month を外部から渡す)かどうか。\n // 制御モードでは月移動は内部状態を変えず onMonthChange に委譲する。\n const controlled = options.year !== undefined || options.month !== undefined;\n const controlledRef = useRef(controlled);\n controlledRef.current = controlled;\n\n // 最新 state を参照するための ref(controlled 分岐で同期的に次月を計算する)\n const stateRef = useRef(state);\n stateRef.current = state;\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 // 制御モードでは props 側が月を決めているので再通知しない(二重通知の抑止)。\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 setHoveredDate(null);\n if (!controlledRef.current) {\n onMonthChangeRef.current?.(state.year, state.month);\n }\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 if (controlledRef.current) {\n const next = navigateMonth(stateRef.current, \"next\");\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => navigateMonth(prev, \"next\"));\n }, []),\n goPrev: useCallback(() => {\n if (controlledRef.current) {\n const next = navigateMonth(stateRef.current, \"prev\");\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => navigateMonth(prev, \"prev\"));\n }, []),\n navigateYear: useCallback((direction: MonthDirection) => {\n if (controlledRef.current) {\n const next = navigateYear(stateRef.current, direction);\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => navigateYear(prev, direction));\n }, []),\n goToMonth: useCallback((year: number, month: number) => {\n if (controlledRef.current) {\n const next = goToMonth(stateRef.current, year, month);\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => goToMonth(prev, year, month));\n }, []),\n goToDate: useCallback((date: Date) => {\n if (controlledRef.current) {\n const next = goToDate(stateRef.current, date);\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => goToDate(prev, date));\n }, []),\n goToday: useCallback(() => {\n if (controlledRef.current) {\n const next = goToToday(stateRef.current);\n onMonthChangeRef.current?.(next.year, next.month);\n return;\n }\n setState((prev) => goToToday(prev));\n }, []),\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 {\n createDate,\n getYearMonth,\n lastDayOfMonth,\n} 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 /**\n * 表示開始位置を `Date` で指定する。`initialYear` / `initialMonth` を\n * 個別に指定した場合はそちらが優先される。\n */\n initialDate?: Date;\n /** 制御モードの表示年。指定すると initialYear より優先され、月移動は onMonthChange に委譲される */\n year?: number;\n /** 制御モードの表示月 (1-12) */\n month?: 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 /** root 要素に追加するクラス。レイアウトや追加スタイルのフックに使う */\n className?: string;\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 initialDate,\n locale,\n holidayLocale,\n weekStart,\n showWeekNumbers,\n selectionMode,\n highlight,\n range,\n today,\n isDateDisabled,\n year,\n month,\n onMonthChange,\n theme,\n colorScheme,\n size,\n responsive,\n className,\n style,\n renderCell,\n cellData,\n onDateClick,\n onDateHover,\n onDateLeave,\n } = props;\n\n // initialDate は initialYear / initialMonth のショートハンド。\n // 個別指定があればそちらを優先する。\n const initialFromDate =\n initialDate !== undefined ? getYearMonth(initialDate) : undefined;\n\n const hook = useCalendarState({\n initialYear: initialYear ?? initialFromDate?.year,\n initialMonth: initialMonth ?? initialFromDate?.month,\n year,\n month,\n locale,\n holidayLocale,\n weekStart,\n selectionMode,\n today,\n highlight,\n range,\n isDateDisabled,\n onMonthChange,\n });\n\n const {\n state,\n moveCursor,\n goPrev,\n goNext,\n navigateYear,\n setCursorToDate,\n clearSelection,\n selectDateAt,\n 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, e);\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 case \"prevYear\":\n navigateYear(\"prev\");\n break;\n case \"nextYear\":\n navigateYear(\"next\");\n break;\n case \"firstDay\":\n setCursorToDate(createDate(state.year, state.month - 1, 1));\n break;\n case \"lastDay\":\n setCursorToDate(lastDayOfMonth(state.year, state.month));\n break;\n case \"clear\":\n clearSelection();\n break;\n default:\n moveCursor(action);\n }\n },\n [\n moveCursor,\n goPrev,\n goNext,\n navigateYear,\n setCursorToDate,\n clearSelection,\n state.year,\n state.month,\n ],\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 className={className}\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;;;;ACqGA,SAAgB,SAAS,EACvB,MAAM,UACN,MACA,OACA,SAAS,MACT,eACA,YAAY,UACZ,kBAAkB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7D,MAAM,SAAS,YAAY,EAAE,KAAK,CAAC;EACnC,IAAI,WAAW,KAAA,GAAW;EAC1B,EAAE,eAAe;EACjB,QAAQ,QAAR;GACE,KAAK;IACH,OAAO;IACP;GACF,KAAK;IACH,OAAO;IACP;GACF,KAAK;IACH,aAAa,MAAM;IACnB;GACF,KAAK;IACH,aAAa,MAAM;IACnB;GACF,KAAK;IACH,gBAAgB,WAAW,MAAM,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC;IAC1D;GACF,KAAK;IACH,gBAAgB,eAAe,MAAM,MAAM,MAAM,KAAK,CAAC;IACvD;GACF,KAAK;IACH,eAAe;IACf;GACF,SACE,WAAW,MAAM;EACrB;CACF,GACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;EACN,MAAM;CACR,CACF;CAEA,OACE,oBAAC,UAAD;EACE,KAAK;EACL,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,QAAQ,MAAM,QAAQ;EACtB,eAAe,MAAM,QAAQ;EAC7B,WAAW,MAAM,QAAQ;EACR;EACjB,WAAW,MAAM,QAAQ;EACzB,OAAO,MAAM,QAAQ;EACrB,OAAO,MAAM,QAAQ;EACL;EACT;EACM;EACP;EACM;EACD;EACJ;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-calendar-lib/react",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "React 19 calendar components with CSS themes and color schemes",
5
5
  "type": "module",
6
6
  "repository": {
@@ -28,18 +28,18 @@
28
28
  ],
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@typescript-calendar-lib/core": "^0.6.1",
32
- "@typescript-calendar-lib/tui": "^0.6.1",
33
- "@typescript-calendar-lib/web": "^0.6.1"
31
+ "@typescript-calendar-lib/core": "^0.6.2",
32
+ "@typescript-calendar-lib/tui": "^0.6.2",
33
+ "@typescript-calendar-lib/web": "^0.6.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@testing-library/react": "^16",
37
37
  "@types/react": "^19",
38
38
  "@types/react-dom": "^19.3.0",
39
- "jsdom": "^30",
40
- "react": "19.3.0",
41
- "react-dom": "19.3.0",
42
- "vitest": "^5"
39
+ "jsdom": "^31",
40
+ "react": "19.3.1",
41
+ "react-dom": "19.3.1",
42
+ "vitest": "^5.1.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": "^19"