@typescript-calendar-lib/react 0.5.2 → 0.5.3

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
@@ -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`
@@ -58,13 +95,14 @@ export function App() {
58
95
  | `colorScheme` | `ColorSchemeName \| ReactColorScheme` | `"default"` | CSS variable-based colors |
59
96
  | `size` | `CalendarSize` | `"md"` | Cell size |
60
97
  | `responsive` | `boolean` | `false` | Shrink cells & padding below `480px` so the grid fits phone screens |
98
+ | `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
99
  | `style` | `CSSProperties` | — | Extra styles for the root element |
62
100
  | `interactive` | `boolean` | `false` | Enable cell click/hover/keyboard selection |
63
101
  | `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
102
  | `onDateHover` | `(date: Date) => void` | — | Called when a day cell is hovered |
65
103
  | `onDateLeave` | `() => void` | — | Called when the mouse leaves the calendar |
66
104
  | `onKeyDown` | `(e: KeyboardEvent) => void` | — | Keyboard handler on the grid element |
67
- | `selectedDate` | `Date \| null` | `null` | Marks the cell `aria-selected` |
105
+ | `selectedDate` | `Date \| null` | `null` | Marks the gridcell `aria-selected` and its interactive button `aria-pressed` |
68
106
  | `cursorDate` | `Date \| null` | `null` | The cell that gets `tabIndex=0` (roving tabindex) |
69
107
  | `hoveredDate` | `Date \| null` | `null` | Marks the hovered cell with the `is-hovered` class |
70
108
  | `cellData` | `(date: Date) => unknown` | — | Resolve per-cell data; passed to `renderCell` and `onDateClick` |
@@ -109,9 +147,11 @@ function App() {
109
147
  selectDate, // () => void — select date under cursor
110
148
  setCursorToDate, // (date) => void — move cursor to a date (same month only)
111
149
  selectDateAt, // (date) => void — move cursor to a date and select it
150
+ selectRange, // (from, to) => void — set a committed range (range mode)
112
151
  clearSelection,
113
152
  cursorDate, // Date | null
114
153
  selectedDate, // Date | null
154
+ selectedRange, // DateRange | null — committed range (range mode)
115
155
  hoveredDate, // Date | null
116
156
  setHoveredDate, // (date | null) => void
117
157
  } = useCalendarState({
@@ -135,7 +175,7 @@ function App() {
135
175
  }
136
176
  ```
137
177
 
138
- `options` also accepts `onMonthChange: (year, month) => void`, called whenever the displayed month changes.
178
+ `options` also accepts `selectionMode: "single" | "range"` (default `"single"`) and `onMonthChange: (year, month) => void`, called whenever the displayed month changes.
139
179
 
140
180
  ## InteractiveCalendar
141
181
 
@@ -147,6 +187,7 @@ function App() {
147
187
  | Hover a cell | Tracks the hovered date (adds `is-hovered` class); fires `onDateHover` |
148
188
  | Mouse leaves | Clears the hover state; fires `onDateLeave` |
149
189
  | Selection + hover | Shows a range preview between the selected date and the hovered date (`is-in-range-preview` class) |
190
+ | Picking (range mode) | Alternates anchor → committed range → new anchor (`selectionMode="range"`) |
150
191
  | Arrow keys | Move the cursor (focus follows the cursor cell) |
151
192
  | `PageUp` / `PageDown` | Previous / next month |
152
193
  | Enter / Space | Same as clicking the focused cell (selects it) |
@@ -170,7 +211,29 @@ function App() {
170
211
  }
171
212
  ```
172
213
 
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`).
214
+ It accepts the `useCalendarState` options (`initialYear`, `initialMonth`, `locale`, `weekStart`, `selectionMode`, `highlight`, `range`, `today`, `onMonthChange`) plus the `Calendar` visual props (`theme`, `colorScheme`, `size`, `responsive`, `style`, `cellData`, `renderCell`) and event callbacks (`onDateClick`, `onDateHover`, `onDateLeave`).
215
+
216
+ ## Range selection
217
+
218
+ 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.
219
+
220
+ ```tsx
221
+ <InteractiveCalendar
222
+ initialYear={2026}
223
+ initialMonth={9}
224
+ selectionMode="range"
225
+ />
226
+ ```
227
+
228
+ With the raw hook, use `selectRange(from, to)` to set the range explicitly and read it back from the `selectedRange` return value:
229
+
230
+ ```tsx
231
+ const { state, selectRange, selectedRange } = useCalendarState({
232
+ initialYear: 2026,
233
+ initialMonth: 9,
234
+ selectionMode: "range",
235
+ });
236
+ ```
174
237
 
175
238
  ## Custom Cell Rendering
176
239
 
@@ -351,7 +414,7 @@ The `style` prop can override any CSS variable or add custom styles:
351
414
 
352
415
  ## Cell Classes
353
416
 
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`, and only the cursor cell is tabbable (`tabIndex=0`, roving tabindex).
417
+ Each day cell gets semantic classes you can target with CSS. The table has an `aria-label`, 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
418
 
356
419
  | Class | When |
357
420
  | :--- | :--- |
package/dist/calendar.css CHANGED
@@ -3,6 +3,7 @@
3
3
  --cal-fg: #1e293b;
4
4
  --cal-accent: #dc2626;
5
5
  --cal-weekend-fg: #94a3b8;
6
+ --cal-holiday-fg: #d33;
6
7
  --cal-border: #e2e8f0;
7
8
  --cal-header-bg: #f8fafc;
8
9
  --cal-highlight-bg: #dc2626;
@@ -43,6 +44,14 @@
43
44
  font-weight: 600;
44
45
  }
45
46
 
47
+ .calendar th.calendar-week, .calendar td.calendar-week {
48
+ width: calc(var(--cal-cell-w) * .6);
49
+ min-width: 1.25rem;
50
+ color: var(--cal-weekend-fg);
51
+ font-size: .75rem;
52
+ font-weight: 400;
53
+ }
54
+
46
55
  .calendar .calendar-header {
47
56
  text-align: center;
48
57
  margin-bottom: .5rem;
@@ -60,6 +69,10 @@
60
69
  color: var(--cal-weekend-fg);
61
70
  }
62
71
 
72
+ .calendar td.is-holiday {
73
+ color: var(--cal-holiday-fg, #d33);
74
+ }
75
+
63
76
  .calendar td.is-disabled {
64
77
  color: var(--cal-disabled-fg, var(--cal-weekend-fg));
65
78
  opacity: .5;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { CalendarCellState, CalendarOptions } from "@typescript-calendar-lib/core";
1
+ import { CalendarCellState, CalendarOptions, DateRange } from "@typescript-calendar-lib/core";
2
2
  import { COLOR_SCHEMES, CalendarCustomSize, CalendarSize, CalendarSizeName, ColorSchemeName, THEMES, ThemeName, WebColorScheme, WebTheme, resolveColorScheme, resolveTheme } from "@typescript-calendar-lib/web";
3
- import { CalendarState, CalendarStateOptions, Direction, MonthDirection } from "@typescript-calendar-lib/tui";
3
+ import { CalendarState, CalendarStateOptions, Direction, MonthDirection, SelectionMode } from "@typescript-calendar-lib/tui";
4
4
  import { CSSProperties, KeyboardEvent, ReactNode, Ref } from "react";
5
5
  //#region src/themes.d.ts
6
6
  /** React の見た目定義(web の 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,10 @@ 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
+ /** 選択方式。既定は "single"。範囲選択時はクリックのたびにアンカー→確定→リセットを交互に行う */
139
+ selectionMode?: SelectionMode;
130
140
  /** ハイライト対象日 */
131
141
  highlight?: Date;
132
142
  /** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスで視覚化される */
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { buildMonthGrid, createDate, getCalendarCellState, getMonthName, getWeekdayHeaders, isDateInRange, isSameDay, sortRange as buildRangePreview } from "@typescript-calendar-lib/core";
1
+ import { addDays, buildMonthGrid, createDate, getCalendarCellState, getISOWeek, getMonthName, getWeekOfYear, getWeekdayHeaders, isDateInRange, isSameDay, sortRange as buildRangePreview } from "@typescript-calendar-lib/core";
2
2
  import { COLOR_SCHEMES, THEMES, buildSizeStyle, formatCellLabel, isSizeName, resolveColorScheme, resolveTheme } from "@typescript-calendar-lib/web";
3
3
  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";
4
+ import { clearSelection, createCalendarState, getCursorDate, getSelectedDate, getSelectedRange, goToDate, goToMonth, goToToday, keyToAction, moveCursor, navigateMonth, navigateYear, sameStateOptions, selectDate, selectDateAt, selectRange, setCursorToDate, updateStateOptions } from "@typescript-calendar-lib/tui";
5
5
  import { useCallback, useEffect, useRef, useState } from "react";
6
6
  //#region src/cell-classes.ts
7
7
  /** 日付セルの状態(週末・今日・ハイライト・範囲・選択・カーソル)に応じた CSS クラスを組み立てる */
@@ -9,6 +9,7 @@ function getCellClasses(date, options) {
9
9
  const state = getCalendarCellState(date, options);
10
10
  const classes = [];
11
11
  if (state.isWeekend) classes.push("is-weekend");
12
+ if (state.isHoliday) classes.push("is-holiday");
12
13
  if (state.isToday) classes.push("is-today");
13
14
  if (state.isHighlight) classes.push("is-highlight");
14
15
  if (state.isInRange) classes.push("is-in-range");
@@ -28,10 +29,18 @@ function buildSizeStyle$1(size) {
28
29
  //#endregion
29
30
  //#region src/Calendar.tsx
30
31
  /** 月カレンダーコンポーネント */
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
+ 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 }) {
32
33
  const cellDate = (day) => createDate(year, month - 1, day);
34
+ const weekOf = (row) => {
35
+ const firstIdx = row.findIndex((d) => d !== null);
36
+ if (firstIdx === -1) return null;
37
+ const firstDate = createDate(year, month - 1, row[firstIdx]);
38
+ const weekStartDate = addDays(firstDate, -firstIdx);
39
+ return weekStart === "monday" ? getISOWeek(weekStartDate) : getWeekOfYear(weekStartDate);
40
+ };
33
41
  const className = (day) => getCellClasses(cellDate(day), {
34
42
  today,
43
+ holidayLocale,
35
44
  highlight,
36
45
  range,
37
46
  rangePreview,
@@ -71,9 +80,21 @@ function Calendar({ year, month, locale = "en", weekStart = "sunday", highlight,
71
80
  role: gridRole,
72
81
  "aria-label": title,
73
82
  onKeyDown,
74
- children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: getWeekdayHeaders(locale, weekStart).map((day) => /* @__PURE__ */ jsx("th", { children: day }, day)) }) }), /* @__PURE__ */ jsx("tbody", { children: buildMonthGrid(year, month, weekStart).map((row, i) => {
83
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [showWeekNumbers && /* @__PURE__ */ jsx("th", {
84
+ className: "calendar-week",
85
+ scope: "col",
86
+ "aria-label": "Week number"
87
+ }, "week"), getWeekdayHeaders(locale, weekStart).map((day) => /* @__PURE__ */ jsx("th", {
88
+ scope: "col",
89
+ children: day
90
+ }, day))] }) }), /* @__PURE__ */ jsx("tbody", { children: buildMonthGrid(year, month, weekStart).map((row, i) => {
75
91
  if (row.every((d) => d === null)) return null;
76
- return /* @__PURE__ */ jsx("tr", { children: row.map((day, j) => {
92
+ const week = weekOf(row);
93
+ return /* @__PURE__ */ jsxs("tr", { children: [showWeekNumbers && week !== null && /* @__PURE__ */ jsx("th", {
94
+ className: "calendar-week",
95
+ scope: "row",
96
+ children: week
97
+ }, "week"), row.map((day, j) => {
77
98
  if (day === null) return /* @__PURE__ */ jsx("td", { role: cellRole }, j);
78
99
  const date = cellDate(day);
79
100
  const state = getCalendarCellState(date, {
@@ -100,11 +121,12 @@ function Calendar({ year, month, locale = "en", weekStart = "sunday", highlight,
100
121
  tabIndex: cursor ? 0 : -1,
101
122
  "data-cursor": cursor ? "true" : void 0,
102
123
  "aria-label": formatCellLabel(locale, year, month, day),
124
+ "aria-pressed": selected,
103
125
  disabled: state.isDisabled,
104
126
  children: renderCell ? renderCell(day, date, state, data) : day
105
127
  }) : renderCell ? renderCell(day, date, state, data) : day
106
128
  }, `d-${day}`);
107
- }) }, i);
129
+ })] }, i);
108
130
  }) })]
109
131
  })]
110
132
  });
@@ -115,7 +137,7 @@ function Calendar({ year, month, locale = "en", weekStart = "sunday", highlight,
115
137
  * tui の不変状態マシンを包む React hook。
116
138
  * カレンダーのインタラクティブ操作をシンプルに利用できる。
117
139
  *
118
- * `options` の値(locale / weekStart / today / highlight / range /
140
+ * `options` の値(locale / weekStart / today / highlight / range / selectionMode /
119
141
  * initialYear / initialMonth)が変わると、カーソル・選択を保ったまま
120
142
  * 状態が再構築される。比較は値(Date は getTime)で行うため、インラインで
121
143
  * オプションを渡しても値が同じなら再構築されない。
@@ -162,9 +184,11 @@ function useCalendarState(options = {}) {
162
184
  selectDate: useCallback(() => setState((prev) => selectDate(prev)), []),
163
185
  setCursorToDate: useCallback((date) => setState((prev) => setCursorToDate(prev, date)), []),
164
186
  selectDateAt: useCallback((date) => setState((prev) => selectDateAt(prev, date)), []),
187
+ selectRange: useCallback((from, to) => setState((prev) => selectRange(prev, from, to)), []),
165
188
  clearSelection: useCallback(() => setState((prev) => clearSelection(prev)), []),
166
189
  cursorDate: getCursorDate(state),
167
190
  selectedDate: getSelectedDate(state),
191
+ selectedRange: getSelectedRange(state),
168
192
  hoveredDate,
169
193
  setHoveredDate
170
194
  };
@@ -181,12 +205,14 @@ function useCalendarState(options = {}) {
181
205
  * Enter/Space(クリックと同じ日付選択)
182
206
  */
183
207
  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;
208
+ const { initialYear, initialMonth, locale, holidayLocale, weekStart, selectionMode, highlight, range, today, isDateDisabled, onMonthChange, theme, colorScheme, size, responsive, style, renderCell, cellData, onDateClick, onDateHover, onDateLeave } = props;
185
209
  const hook = useCalendarState({
186
210
  initialYear,
187
211
  initialMonth,
188
212
  locale,
213
+ holidayLocale,
189
214
  weekStart,
215
+ selectionMode,
190
216
  today,
191
217
  highlight,
192
218
  range,
@@ -207,7 +233,7 @@ function InteractiveCalendar(props) {
207
233
  setHoveredDate(null);
208
234
  onDateLeave?.();
209
235
  }, [setHoveredDate, onDateLeave]);
210
- const rangePreview = buildRangePreview(hook.selectedDate, hook.hoveredDate);
236
+ const rangePreview = hook.selectedRange ?? buildRangePreview(hook.selectedDate, hook.hoveredDate);
211
237
  const prevCursorRef = useRef(state.cursor);
212
238
  useEffect(() => {
213
239
  const prev = prevCursorRef.current;
@@ -238,6 +264,7 @@ function InteractiveCalendar(props) {
238
264
  year: state.year,
239
265
  month: state.month,
240
266
  locale: state.options.locale,
267
+ holidayLocale: state.options.holidayLocale,
241
268
  weekStart: state.options.weekStart,
242
269
  highlight: state.options.highlight,
243
270
  range: state.options.range,
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,EACvB,MACA,OACA,SAAS,MACT,YAAY,UACZ,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;CAChB,MAAM,YAAY,QAAsB,WAAW,MAAM,QAAQ,GAAG,GAAG;CACvE,MAAM,aAAa,QACjB,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,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"],"sources":["../src/cell-classes.ts","../src/size.ts","../src/Calendar.tsx","../src/hooks.ts","../src/interactive.tsx"],"sourcesContent":["import type { Locale } from \"@typescript-calendar-lib/core\";\nimport {\n getCalendarCellState,\n isDateInRange,\n isSameDay,\n} from \"@typescript-calendar-lib/core\";\n\n// ─── セル状態クラス ───────────────────────────────────────\n\nexport interface CellStateOptions {\n today?: Date;\n /** 祝日の判定に使うロケール。省略時は \"ja\" */\n holidayLocale?: Locale;\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.isHoliday) classes.push(\"is-holiday\");\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 addDays,\n buildMonthGrid,\n createDate,\n getCalendarCellState,\n getISOWeek,\n getMonthName,\n getWeekdayHeaders,\n getWeekOfYear,\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 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 const cellDate = (day: number): Date => createDate(year, month - 1, day);\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 const className = (day: number): string | undefined =>\n getCellClasses(cellDate(day), {\n today,\n holidayLocale,\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 {showWeekNumbers && (\n <th\n key=\"week\"\n className=\"calendar-week\"\n scope=\"col\"\n aria-label=\"Week number\"\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 {buildMonthGrid(year, month, weekStart).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 key=\"week\" className=\"calendar-week\" scope=\"row\">\n {week}\n </th>\n )}\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 aria-pressed={selected}\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 { 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 /** 選択方式。既定は \"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 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 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":";;;;;;;AA8BA,SAAgB,eAAe,MAAY,SAAmC;CAC5E,MAAM,QAAQ,qBAAqB,MAAM,OAAO;CAChD,MAAM,UAAoB,CAAC;CAC3B,IAAI,MAAM,WAAW,QAAQ,KAAK,YAAY;CAC9C,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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,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,eAAe,MAAM,QAAQ;EAC7B,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-calendar-lib/react",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
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.2",
32
- "@typescript-calendar-lib/tui": "0.5.2",
33
- "@typescript-calendar-lib/web": "0.5.2"
31
+ "@typescript-calendar-lib/core": "^0.5.3",
32
+ "@typescript-calendar-lib/tui": "^0.5.3",
33
+ "@typescript-calendar-lib/web": "^0.5.3"
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",