@typescript-calendar-lib/react 0.3.0 → 0.4.1
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 +66 -1
- package/dist/index.d.ts +75 -20
- package/dist/index.js +173 -79
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@ A `<Calendar />` React component with CSS-based themes and color schemes, plus a
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
+
pnpm add @typescript-calendar-lib/react
|
|
15
|
+
# or
|
|
14
16
|
npm install @typescript-calendar-lib/react
|
|
15
17
|
# or
|
|
16
18
|
bun add @typescript-calendar-lib/react
|
|
@@ -58,6 +60,10 @@ export function App() {
|
|
|
58
60
|
| `interactive` | `boolean` | `false` | Enable cell click/hover/keyboard selection |
|
|
59
61
|
| `onDateClick` | `(date: Date) => void` | — | Called when a day cell is clicked (or Enter/Space pressed) |
|
|
60
62
|
| `onDateHover` | `(date: Date) => void` | — | Called when a day cell is hovered |
|
|
63
|
+
| `onKeyDown` | `(e: KeyboardEvent) => void` | — | Keyboard handler on the grid element |
|
|
64
|
+
| `selectedDate` | `Date \| null` | `null` | Marks the cell `aria-selected` |
|
|
65
|
+
| `cursorDate` | `Date \| null` | `null` | The cell that gets `tabIndex=0` (roving tabindex) |
|
|
66
|
+
| `renderCell` | `(day, date, state) => ReactNode` | — | Custom cell content renderer |
|
|
61
67
|
|
|
62
68
|
The component exports as both named `Calendar` and default.
|
|
63
69
|
|
|
@@ -89,6 +95,9 @@ function App() {
|
|
|
89
95
|
goNext, // () => void — next month
|
|
90
96
|
goPrev, // () => void — previous month
|
|
91
97
|
goToday, // () => void — jump to today
|
|
98
|
+
navigateYear, // (direction) => void — "prev" | "next" year
|
|
99
|
+
goToMonth, // (year, month) => void — jump to a specific month
|
|
100
|
+
goToDate, // (date) => void — jump to a date's month, cursor on that date
|
|
92
101
|
moveCursor, // (direction) => void — "up" | "down" | "left" | "right"
|
|
93
102
|
selectDate, // () => void — select date under cursor
|
|
94
103
|
clearSelection,
|
|
@@ -109,6 +118,60 @@ function App() {
|
|
|
109
118
|
}
|
|
110
119
|
```
|
|
111
120
|
|
|
121
|
+
`options` also accepts `onMonthChange: (year, month) => void`, called whenever the displayed month changes.
|
|
122
|
+
|
|
123
|
+
## InteractiveCalendar
|
|
124
|
+
|
|
125
|
+
`InteractiveCalendar` bundles `useCalendarState` + `<Calendar>` into a single self-contained component. It manages its own state and supports keyboard navigation out of the box:
|
|
126
|
+
|
|
127
|
+
| Key | Action |
|
|
128
|
+
| :--- | :--- |
|
|
129
|
+
| Arrow keys | Move the cursor (focus follows the cursor cell) |
|
|
130
|
+
| `PageUp` / `PageDown` | Previous / next month |
|
|
131
|
+
| Enter / Space | Same as clicking the focused cell |
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { InteractiveCalendar } from "@typescript-calendar-lib/react";
|
|
135
|
+
import "@typescript-calendar-lib/react/calendar.css"; // required — component styles
|
|
136
|
+
|
|
137
|
+
function App() {
|
|
138
|
+
return (
|
|
139
|
+
<InteractiveCalendar
|
|
140
|
+
initialYear={2026}
|
|
141
|
+
initialMonth={9}
|
|
142
|
+
theme="modern"
|
|
143
|
+
colorScheme="ocean"
|
|
144
|
+
onMonthChange={(year, month) => console.log("Month:", year, month)}
|
|
145
|
+
onDateClick={(date) => console.log("Selected", date)}
|
|
146
|
+
/>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
It accepts the `useCalendarState` options (`initialYear`, `initialMonth`, `locale`, `weekStart`, `highlight`, `range`, `today`, `onMonthChange`) plus the `Calendar` visual props (`theme`, `colorScheme`, `size`, `style`, `renderCell`) and event callbacks (`onDateClick`, `onDateHover`).
|
|
152
|
+
|
|
153
|
+
## Custom Cell Rendering
|
|
154
|
+
|
|
155
|
+
Pass `renderCell` to replace the default day-number content of each cell. It receives the day, the full `Date`, and the cell state:
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import type { CalendarCellState } from "@typescript-calendar-lib/core";
|
|
159
|
+
|
|
160
|
+
<Calendar
|
|
161
|
+
year={2026}
|
|
162
|
+
month={9}
|
|
163
|
+
renderCell={(day, date, state) => (
|
|
164
|
+
<span>
|
|
165
|
+
{day}
|
|
166
|
+
{state.isToday && "★"}
|
|
167
|
+
{state.isInRange && "•"}
|
|
168
|
+
</span>
|
|
169
|
+
)}
|
|
170
|
+
/>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
112
175
|
See the interactive demo in the repository docs (`docs/guide/interactive-demo.md`) for a complete example.
|
|
113
176
|
|
|
114
177
|
## Themes
|
|
@@ -239,7 +302,7 @@ The `style` prop can override any CSS variable or add custom styles:
|
|
|
239
302
|
|
|
240
303
|
## Cell Classes
|
|
241
304
|
|
|
242
|
-
Each day cell gets semantic classes you can target with CSS:
|
|
305
|
+
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).
|
|
243
306
|
|
|
244
307
|
| Class | When |
|
|
245
308
|
| :--- | :--- |
|
|
@@ -258,6 +321,7 @@ import Calendar, {
|
|
|
258
321
|
resolveTheme,
|
|
259
322
|
THEMES,
|
|
260
323
|
useCalendarState,
|
|
324
|
+
InteractiveCalendar,
|
|
261
325
|
} from "@typescript-calendar-lib/react";
|
|
262
326
|
|
|
263
327
|
import type {
|
|
@@ -266,6 +330,7 @@ import type {
|
|
|
266
330
|
CalendarSize,
|
|
267
331
|
CalendarSizeName,
|
|
268
332
|
ColorSchemeName,
|
|
333
|
+
InteractiveCalendarProps,
|
|
269
334
|
ReactColorScheme,
|
|
270
335
|
ReactTheme,
|
|
271
336
|
ThemeName,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CalendarOptions } from "@typescript-calendar-lib/core";
|
|
2
|
-
import { CalendarState, CalendarStateOptions, Direction } from "@typescript-calendar-lib/tui";
|
|
3
|
-
import { CSSProperties } from "react";
|
|
1
|
+
import { CalendarCellState, CalendarOptions } from "@typescript-calendar-lib/core";
|
|
2
|
+
import { CalendarState, CalendarStateOptions, Direction, MonthDirection } from "@typescript-calendar-lib/tui";
|
|
3
|
+
import { CSSProperties, KeyboardEvent, ReactNode, Ref } from "react";
|
|
4
4
|
//#region src/size.d.ts
|
|
5
5
|
/** 組み込みサイズ名 */
|
|
6
6
|
type CalendarSizeName = "sm" | "md" | "lg";
|
|
@@ -29,10 +29,54 @@ type ReactColorScheme = Record<`--cal-${string}`, string>;
|
|
|
29
29
|
export declare const COLOR_SCHEMES: Record<ColorSchemeName, ReactColorScheme>;
|
|
30
30
|
export declare function resolveColorScheme(scheme?: ColorSchemeName | ReactColorScheme): ReactColorScheme;
|
|
31
31
|
//#endregion
|
|
32
|
+
//#region src/Calendar.d.ts
|
|
33
|
+
interface CalendarProps {
|
|
34
|
+
year: number;
|
|
35
|
+
month: number;
|
|
36
|
+
locale?: CalendarOptions["locale"];
|
|
37
|
+
weekStart?: CalendarOptions["weekStart"];
|
|
38
|
+
highlight?: Date;
|
|
39
|
+
/** 範囲強調 */
|
|
40
|
+
range?: {
|
|
41
|
+
from: Date;
|
|
42
|
+
to: Date;
|
|
43
|
+
};
|
|
44
|
+
/** 今日の基準日。カラースキームの today 着色に使用 */
|
|
45
|
+
today?: Date;
|
|
46
|
+
/** 見た目テーマ。既定は "default" */
|
|
47
|
+
theme?: ThemeName | ReactTheme;
|
|
48
|
+
/** カラースキーム。既定は "default" */
|
|
49
|
+
colorScheme?: ColorSchemeName | ReactColorScheme;
|
|
50
|
+
/** セルサイズ。既定は "md"。{ width, height } で自由に指定できる */
|
|
51
|
+
size?: CalendarSize;
|
|
52
|
+
/** root 要素に追加するスタイル。CSS変数(--cal-*)で自由に上書きできる */
|
|
53
|
+
style?: CSSProperties;
|
|
54
|
+
/** インタラクティブモードを有効にする。セルクリック・ホバー・キーボード選択が可能になる */
|
|
55
|
+
interactive?: boolean;
|
|
56
|
+
/** セルクリック時のコールバック */
|
|
57
|
+
onDateClick?: (date: Date) => void;
|
|
58
|
+
/** セルホバー時のコールバック */
|
|
59
|
+
onDateHover?: (date: Date) => void;
|
|
60
|
+
/** キーボード操作。root 要素で発火(矢印キー等を InteractiveCalendar が処理する) */
|
|
61
|
+
onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
62
|
+
/** 選択済み日付。aria-selected と表示スタイルに使用 */
|
|
63
|
+
selectedDate?: Date | null;
|
|
64
|
+
/** カーソル位置の日付。このセルだけ tabIndex=0(roving tabindex)になる */
|
|
65
|
+
cursorDate?: Date | null;
|
|
66
|
+
/** セル内容のカスタムレンダリング。interactive 時は button の子として描画される */
|
|
67
|
+
renderCell?: (day: number, date: Date, state: CalendarCellState) => ReactNode;
|
|
68
|
+
/** root 要素への ref(React 19 の ref-as-prop) */
|
|
69
|
+
ref?: Ref<HTMLDivElement>;
|
|
70
|
+
}
|
|
71
|
+
/** 月カレンダーコンポーネント */
|
|
72
|
+
export declare function Calendar({ year, month, locale, weekStart, highlight, range, today, theme, colorScheme, size, style, interactive, onDateClick, onDateHover, onKeyDown, selectedDate, cursorDate, renderCell, ref }: CalendarProps): import("react").JSX.Element;
|
|
73
|
+
//#endregion
|
|
32
74
|
//#region src/hooks.d.ts
|
|
33
75
|
interface UseCalendarStateOptions extends Pick<CalendarStateOptions, "locale" | "weekStart" | "today" | "highlight" | "range"> {
|
|
34
76
|
initialYear?: number;
|
|
35
77
|
initialMonth?: number;
|
|
78
|
+
/** 表示中の年月が変わったときに呼ばれる */
|
|
79
|
+
onMonthChange?: (year: number, month: number) => void;
|
|
36
80
|
}
|
|
37
81
|
interface UseCalendarStateReturn {
|
|
38
82
|
/** 現在のカレンダー状態 */
|
|
@@ -42,6 +86,12 @@ interface UseCalendarStateReturn {
|
|
|
42
86
|
/** 前月/翌月へ移動 */
|
|
43
87
|
goNext: () => void;
|
|
44
88
|
goPrev: () => void;
|
|
89
|
+
/** 前年/翌年へ移動 */
|
|
90
|
+
navigateYear: (direction: MonthDirection) => void;
|
|
91
|
+
/** 指定した年月へジャンプ */
|
|
92
|
+
goToMonth: (year: number, month: number) => void;
|
|
93
|
+
/** 指定した日付の月へジャンプし、カーソルをその日付に置く */
|
|
94
|
+
goToDate: (date: Date) => void;
|
|
45
95
|
/** 今日の月へジャンプ */
|
|
46
96
|
goToday: () => void;
|
|
47
97
|
/** カーソル位置の日付を選択 */
|
|
@@ -67,37 +117,42 @@ interface UseCalendarStateReturn {
|
|
|
67
117
|
*/
|
|
68
118
|
export declare function useCalendarState(options?: UseCalendarStateOptions): UseCalendarStateReturn;
|
|
69
119
|
//#endregion
|
|
70
|
-
//#region src/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
120
|
+
//#region src/interactive.d.ts
|
|
121
|
+
interface InteractiveCalendarProps {
|
|
122
|
+
/** 表示開始年。既定は today の年 */
|
|
123
|
+
initialYear?: number;
|
|
124
|
+
/** 表示開始月 (1-12)。範囲外は正規化される */
|
|
125
|
+
initialMonth?: number;
|
|
74
126
|
locale?: CalendarOptions["locale"];
|
|
75
127
|
weekStart?: CalendarOptions["weekStart"];
|
|
128
|
+
/** ハイライト対象日 */
|
|
76
129
|
highlight?: Date;
|
|
77
|
-
/**
|
|
130
|
+
/** 色付け範囲 */
|
|
78
131
|
range?: {
|
|
79
132
|
from: Date;
|
|
80
133
|
to: Date;
|
|
81
134
|
};
|
|
82
|
-
/**
|
|
135
|
+
/** 今日の基準日。省略時は初回レンダリング時刻に解決される */
|
|
83
136
|
today?: Date;
|
|
84
|
-
/**
|
|
137
|
+
/** 表示中の年月が変わったときに呼ばれる */
|
|
138
|
+
onMonthChange?: (year: number, month: number) => void;
|
|
85
139
|
theme?: ThemeName | ReactTheme;
|
|
86
|
-
/** カラースキーム。既定は "default" */
|
|
87
140
|
colorScheme?: ColorSchemeName | ReactColorScheme;
|
|
88
|
-
/** セルサイズ。既定は "md"。{ width, height } で自由に指定できる */
|
|
89
141
|
size?: CalendarSize;
|
|
90
|
-
/** root 要素に追加するスタイル。CSS変数(--cal-*)で自由に上書きできる */
|
|
91
142
|
style?: CSSProperties;
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
/**
|
|
143
|
+
/** セル内容のカスタムレンダリング */
|
|
144
|
+
renderCell?: CalendarProps["renderCell"];
|
|
145
|
+
/** セルクリック時(キーボードの Enter/Space 含む) */
|
|
95
146
|
onDateClick?: (date: Date) => void;
|
|
96
|
-
/**
|
|
147
|
+
/** セルホバー時 */
|
|
97
148
|
onDateHover?: (date: Date) => void;
|
|
98
149
|
}
|
|
99
|
-
/**
|
|
100
|
-
|
|
150
|
+
/**
|
|
151
|
+
* `useCalendarState` と `Calendar` を一体化したインタラクティブカレンダー。
|
|
152
|
+
* 内部で状態を管理し、矢印キー(カーソル移動)・PageUp/PageDown(月移動)の
|
|
153
|
+
* キーボード操作に対応する。
|
|
154
|
+
*/
|
|
155
|
+
export declare function InteractiveCalendar(props: InteractiveCalendarProps): import("react").JSX.Element;
|
|
101
156
|
//#endregion
|
|
102
|
-
export { Calendar as default, type CalendarCustomSize, type CalendarSize, type CalendarSizeName, type ColorSchemeName, type ReactColorScheme, type ReactTheme, type ThemeName, type UseCalendarStateOptions, type UseCalendarStateReturn };
|
|
157
|
+
export { Calendar as default, type CalendarCustomSize, type CalendarProps, type CalendarSize, type CalendarSizeName, type ColorSchemeName, type InteractiveCalendarProps, type ReactColorScheme, type ReactTheme, type ThemeName, type UseCalendarStateOptions, type UseCalendarStateReturn };
|
|
103
158
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { buildMonthGrid, createDate, getMonthName, getWeekdayHeaders,
|
|
1
|
+
import { buildMonthGrid, createDate, getCalendarCellState, getMonthName, getWeekdayHeaders, isSameDay } from "@typescript-calendar-lib/core";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { clearSelection, createCalendarState, getCursorDate, getSelectedDate, goToDate, goToMonth, goToToday, moveCursor, navigateMonth, navigateYear, sameStateOptions, selectDate, updateStateOptions } from "@typescript-calendar-lib/tui";
|
|
4
4
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
5
5
|
//#region src/cell-classes.ts
|
|
6
|
-
/**
|
|
7
|
-
function
|
|
6
|
+
/** セル状態に応じた CSS クラスを組み立てる */
|
|
7
|
+
function stateToClasses(state) {
|
|
8
8
|
const classes = [];
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
if (
|
|
12
|
-
if (
|
|
13
|
-
if (options.range && isDateInRange(date, options.range)) classes.push("is-in-range");
|
|
9
|
+
if (state.isWeekend) classes.push("is-weekend");
|
|
10
|
+
if (state.isToday) classes.push("is-today");
|
|
11
|
+
if (state.isHighlight) classes.push("is-highlight");
|
|
12
|
+
if (state.isInRange) classes.push("is-in-range");
|
|
14
13
|
return classes.join(" ");
|
|
15
14
|
}
|
|
16
15
|
//#endregion
|
|
@@ -160,15 +159,73 @@ function resolveColorScheme(scheme) {
|
|
|
160
159
|
return scheme;
|
|
161
160
|
}
|
|
162
161
|
//#endregion
|
|
163
|
-
//#region src/
|
|
164
|
-
/**
|
|
165
|
-
function
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
162
|
+
//#region src/Calendar.tsx
|
|
163
|
+
/** 月カレンダーコンポーネント */
|
|
164
|
+
function Calendar({ year, month, locale = "en", weekStart = "sunday", highlight, range, today, theme = "default", colorScheme = "default", size = "md", style, interactive = false, onDateClick, onDateHover, onKeyDown, selectedDate = null, cursorDate = null, renderCell, ref }) {
|
|
165
|
+
const cellDate = (day) => createDate(year, month - 1, day);
|
|
166
|
+
const cellState = (day) => getCalendarCellState(cellDate(day), {
|
|
167
|
+
today,
|
|
168
|
+
highlight,
|
|
169
|
+
range
|
|
170
|
+
});
|
|
171
|
+
const cellClass = (day) => stateToClasses(cellState(day)) || void 0;
|
|
172
|
+
const isSelected = (day) => selectedDate !== null && isSameDay(cellDate(day), selectedDate);
|
|
173
|
+
const isCursor = (day) => cursorDate !== null && isSameDay(cellDate(day), cursorDate);
|
|
174
|
+
const handleCellClick = (day) => {
|
|
175
|
+
if (interactive && onDateClick) onDateClick(cellDate(day));
|
|
176
|
+
};
|
|
177
|
+
const handleCellHover = (day) => {
|
|
178
|
+
if (interactive && onDateHover) onDateHover(cellDate(day));
|
|
179
|
+
};
|
|
180
|
+
const title = `${getMonthName(locale, month)} ${year}`;
|
|
181
|
+
const gridRole = interactive ? "grid" : void 0;
|
|
182
|
+
const cellRole = interactive ? "gridcell" : void 0;
|
|
183
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
184
|
+
ref,
|
|
185
|
+
className: `calendar ${resolveTheme(theme).className}${isSizeName(size) ? ` calendar-size-${size}` : ""}${interactive ? " calendar-interactive" : ""}`,
|
|
186
|
+
style: {
|
|
187
|
+
...resolveColorScheme(colorScheme),
|
|
188
|
+
...buildSizeStyle(size),
|
|
189
|
+
...style
|
|
190
|
+
},
|
|
191
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
192
|
+
className: "calendar-header",
|
|
193
|
+
children: /* @__PURE__ */ jsx("h2", { children: title })
|
|
194
|
+
}), /* @__PURE__ */ jsxs("table", {
|
|
195
|
+
role: gridRole,
|
|
196
|
+
"aria-label": title,
|
|
197
|
+
onKeyDown,
|
|
198
|
+
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) => {
|
|
199
|
+
if (row.every((d) => d === null)) return null;
|
|
200
|
+
return /* @__PURE__ */ jsx("tr", { children: row.map((day, j) => {
|
|
201
|
+
if (day === null) return /* @__PURE__ */ jsx("td", { role: cellRole }, j);
|
|
202
|
+
const state = cellState(day);
|
|
203
|
+
const selected = isSelected(day);
|
|
204
|
+
const cursor = isCursor(day);
|
|
205
|
+
return /* @__PURE__ */ jsx("td", {
|
|
206
|
+
role: cellRole,
|
|
207
|
+
tabIndex: interactive ? -1 : void 0,
|
|
208
|
+
className: cellClass(day),
|
|
209
|
+
"aria-selected": selected || void 0,
|
|
210
|
+
"aria-current": state.isToday ? "date" : void 0,
|
|
211
|
+
children: interactive ? /* @__PURE__ */ jsx("button", {
|
|
212
|
+
type: "button",
|
|
213
|
+
className: "calendar-day-btn",
|
|
214
|
+
onClick: () => handleCellClick(day),
|
|
215
|
+
onMouseEnter: () => handleCellHover(day),
|
|
216
|
+
tabIndex: cursor ? 0 : -1,
|
|
217
|
+
"data-cursor": cursor ? "true" : void 0,
|
|
218
|
+
"aria-label": `${getMonthName(locale, month)} ${day}, ${year}`,
|
|
219
|
+
children: renderCell ? renderCell(day, cellDate(day), state) : day
|
|
220
|
+
}) : renderCell ? renderCell(day, cellDate(day), state) : day
|
|
221
|
+
}, day);
|
|
222
|
+
}) }, i);
|
|
223
|
+
}) })]
|
|
224
|
+
})]
|
|
225
|
+
});
|
|
171
226
|
}
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/hooks.ts
|
|
172
229
|
/**
|
|
173
230
|
* tui の不変状態マシンを包む React hook。
|
|
174
231
|
* カレンダーのインタラクティブ操作をシンプルに利用できる。
|
|
@@ -193,29 +250,35 @@ function useCalendarState(options = {}) {
|
|
|
193
250
|
}));
|
|
194
251
|
const prevOptions = useRef(options);
|
|
195
252
|
useEffect(() => {
|
|
196
|
-
if (
|
|
197
|
-
const
|
|
198
|
-
const prevInitialMonth = prevOptions.current.initialMonth;
|
|
253
|
+
if (sameStateOptions(prevOptions.current, options)) return;
|
|
254
|
+
const previous = prevOptions.current;
|
|
199
255
|
prevOptions.current = options;
|
|
200
|
-
setState((
|
|
201
|
-
const resolved = resolveOptions({
|
|
202
|
-
today: options.today ?? prev.options.today,
|
|
203
|
-
locale: options.locale ?? prev.options.locale,
|
|
204
|
-
weekStart: options.weekStart ?? prev.options.weekStart,
|
|
205
|
-
highlight: options.highlight,
|
|
206
|
-
range: options.range
|
|
207
|
-
});
|
|
208
|
-
const year = options.initialYear !== void 0 && options.initialYear !== prevInitialYear ? options.initialYear : prev.year;
|
|
209
|
-
const month = options.initialMonth !== void 0 && options.initialMonth !== prevInitialMonth ? options.initialMonth : prev.month;
|
|
210
|
-
const monthData = buildMonthData(year, month, resolved);
|
|
211
|
-
return rebuildState(year, month, prev.cursor, prev.selectedDate, resolved, monthData);
|
|
212
|
-
});
|
|
256
|
+
setState((current) => updateStateOptions(current, options, previous));
|
|
213
257
|
}, [options]);
|
|
258
|
+
const onMonthChangeRef = useRef(options.onMonthChange);
|
|
259
|
+
onMonthChangeRef.current = options.onMonthChange;
|
|
260
|
+
const prevMonthRef = useRef({
|
|
261
|
+
year: state.year,
|
|
262
|
+
month: state.month
|
|
263
|
+
});
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
const prev = prevMonthRef.current;
|
|
266
|
+
if (prev.year !== state.year || prev.month !== state.month) {
|
|
267
|
+
prevMonthRef.current = {
|
|
268
|
+
year: state.year,
|
|
269
|
+
month: state.month
|
|
270
|
+
};
|
|
271
|
+
onMonthChangeRef.current?.(state.year, state.month);
|
|
272
|
+
}
|
|
273
|
+
}, [state.year, state.month]);
|
|
214
274
|
return {
|
|
215
275
|
state,
|
|
216
276
|
moveCursor: useCallback((direction) => setState((prev) => moveCursor(prev, direction)), []),
|
|
217
277
|
goNext: useCallback(() => setState((prev) => navigateMonth(prev, "next")), []),
|
|
218
278
|
goPrev: useCallback(() => setState((prev) => navigateMonth(prev, "prev")), []),
|
|
279
|
+
navigateYear: useCallback((direction) => setState((prev) => navigateYear(prev, direction)), []),
|
|
280
|
+
goToMonth: useCallback((year, month) => setState((prev) => goToMonth(prev, year, month)), []),
|
|
281
|
+
goToDate: useCallback((date) => setState((prev) => goToDate(prev, date)), []),
|
|
219
282
|
goToday: useCallback(() => setState((prev) => goToToday(prev)), []),
|
|
220
283
|
selectDate: useCallback(() => setState((prev) => selectDate(prev)), []),
|
|
221
284
|
clearSelection: useCallback(() => setState((prev) => clearSelection(prev)), []),
|
|
@@ -224,56 +287,87 @@ function useCalendarState(options = {}) {
|
|
|
224
287
|
};
|
|
225
288
|
}
|
|
226
289
|
//#endregion
|
|
227
|
-
//#region src/
|
|
228
|
-
/**
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
290
|
+
//#region src/interactive.tsx
|
|
291
|
+
/**
|
|
292
|
+
* `useCalendarState` と `Calendar` を一体化したインタラクティブカレンダー。
|
|
293
|
+
* 内部で状態を管理し、矢印キー(カーソル移動)・PageUp/PageDown(月移動)の
|
|
294
|
+
* キーボード操作に対応する。
|
|
295
|
+
*/
|
|
296
|
+
function InteractiveCalendar(props) {
|
|
297
|
+
const { initialYear, initialMonth, locale, weekStart, highlight, range, today, onMonthChange, theme, colorScheme, size, style, renderCell, onDateClick, onDateHover } = props;
|
|
298
|
+
const hook = useCalendarState({
|
|
299
|
+
initialYear,
|
|
300
|
+
initialMonth,
|
|
301
|
+
locale,
|
|
302
|
+
weekStart,
|
|
232
303
|
today,
|
|
233
304
|
highlight,
|
|
234
|
-
range
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
305
|
+
range,
|
|
306
|
+
onMonthChange
|
|
307
|
+
});
|
|
308
|
+
const { state, moveCursor, goPrev, goNext } = hook;
|
|
309
|
+
const rootRef = useRef(null);
|
|
310
|
+
const prevCursorRef = useRef(state.cursor);
|
|
311
|
+
useEffect(() => {
|
|
312
|
+
const prev = prevCursorRef.current;
|
|
313
|
+
prevCursorRef.current = state.cursor;
|
|
314
|
+
if (prev === state.cursor) return;
|
|
315
|
+
(rootRef.current?.querySelector("[data-cursor=\"true\"]"))?.focus();
|
|
316
|
+
}, [state.cursor]);
|
|
317
|
+
const handleKeyDown = useCallback((e) => {
|
|
318
|
+
switch (e.key) {
|
|
319
|
+
case "ArrowRight":
|
|
320
|
+
e.preventDefault();
|
|
321
|
+
moveCursor("right");
|
|
322
|
+
break;
|
|
323
|
+
case "ArrowLeft":
|
|
324
|
+
e.preventDefault();
|
|
325
|
+
moveCursor("left");
|
|
326
|
+
break;
|
|
327
|
+
case "ArrowDown":
|
|
328
|
+
e.preventDefault();
|
|
329
|
+
moveCursor("down");
|
|
330
|
+
break;
|
|
331
|
+
case "ArrowUp":
|
|
332
|
+
e.preventDefault();
|
|
333
|
+
moveCursor("up");
|
|
334
|
+
break;
|
|
335
|
+
case "PageUp":
|
|
336
|
+
e.preventDefault();
|
|
337
|
+
goPrev();
|
|
338
|
+
break;
|
|
339
|
+
case "PageDown":
|
|
340
|
+
e.preventDefault();
|
|
341
|
+
goNext();
|
|
342
|
+
}
|
|
343
|
+
}, [
|
|
344
|
+
moveCursor,
|
|
345
|
+
goPrev,
|
|
346
|
+
goNext
|
|
347
|
+
]);
|
|
348
|
+
return /* @__PURE__ */ jsx(Calendar, {
|
|
349
|
+
ref: rootRef,
|
|
350
|
+
year: state.year,
|
|
351
|
+
month: state.month,
|
|
352
|
+
locale: state.options.locale,
|
|
353
|
+
weekStart: state.options.weekStart,
|
|
354
|
+
highlight: state.options.highlight,
|
|
355
|
+
range: state.options.range,
|
|
356
|
+
today: state.options.today,
|
|
357
|
+
theme,
|
|
358
|
+
colorScheme,
|
|
359
|
+
size,
|
|
360
|
+
style,
|
|
361
|
+
interactive: true,
|
|
362
|
+
renderCell,
|
|
363
|
+
selectedDate: hook.selectedDate,
|
|
364
|
+
cursorDate: hook.cursorDate,
|
|
365
|
+
onDateClick,
|
|
366
|
+
onDateHover,
|
|
367
|
+
onKeyDown: handleKeyDown
|
|
274
368
|
});
|
|
275
369
|
}
|
|
276
370
|
//#endregion
|
|
277
|
-
export { COLOR_SCHEMES, Calendar, Calendar as default, THEMES, resolveColorScheme, resolveTheme, useCalendarState };
|
|
371
|
+
export { COLOR_SCHEMES, Calendar, Calendar as default, InteractiveCalendar, THEMES, resolveColorScheme, resolveTheme, useCalendarState };
|
|
278
372
|
|
|
279
373
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/cell-classes.ts","../src/size.ts","../src/themes.ts","../src/hooks.ts","../src/index.tsx"],"sourcesContent":["import { isDateInRange, isSameDay } from \"@typescript-calendar-lib/core\";\n\n// ─── セル状態クラス ───────────────────────────────────────\n\nexport interface CellStateOptions {\n today?: Date;\n highlight?: Date;\n range?: { from: Date; to: Date };\n}\n\n// 範囲の from > to は不正入力として RangeError(isDateInRange が検証する)\n\n/** 日付セルの状態(週末・今日・ハイライト・範囲)に応じたCSSクラスを組み立てる */\nexport function getCellClasses(date: Date, options: CellStateOptions): string {\n const classes: string[] = [];\n const dow = date.getDay();\n if (dow === 0 || dow === 6) classes.push(\"is-weekend\");\n if (options.today && isSameDay(date, options.today)) classes.push(\"is-today\");\n if (options.highlight && isSameDay(date, options.highlight))\n classes.push(\"is-highlight\");\n if (options.range && isDateInRange(date, options.range))\n classes.push(\"is-in-range\");\n return classes.join(\" \");\n}\n","import type { CSSProperties } from \"react\";\n\n// ─── セルサイズ ───────────────────────────────────────────\n\n/** 組み込みサイズ名 */\nexport type CalendarSizeName = \"sm\" | \"md\" | \"lg\";\n\n/** カスタムセルサイズ。数値は px、文字列は CSS 長さのまま渡す */\nexport interface CalendarCustomSize {\n width?: number | string;\n height?: number | string;\n}\n\n/** セルサイズ指定 */\nexport type CalendarSize = CalendarSizeName | CalendarCustomSize;\n\n/** 組み込みサイズ名のみ真を返す(未知の文字列はカスタムサイズとして扱わない) */\nexport function isSizeName(size: CalendarSize): size is CalendarSizeName {\n return typeof size === \"string\" && [\"sm\", \"md\", \"lg\"].includes(size);\n}\n\nfunction toCssLength(value: number | string): string {\n return typeof value === \"number\" ? `${value}px` : value;\n}\n\nexport function buildSizeStyle(size: CalendarSize): CSSProperties {\n if (isSizeName(size)) return {};\n const style: Record<string, string> = {};\n if (size.width !== undefined) style[\"--cal-cell-w\"] = toCssLength(size.width);\n if (size.height !== undefined)\n style[\"--cal-cell-h\"] = toCssLength(size.height);\n return style;\n}\n","// ─── テーマ ───────────────────────────────────────────────\n\n/** 組み込みテーマ名。カスタムテーマは ReactTheme オブジェクトを直接渡せる */\nexport type ThemeName = \"default\" | \"modern\" | \"minimal\" | \"rounded\" | \"retro\";\n\n/** React の見た目定義。テーマは主に CSS クラスで切り替える */\nexport interface ReactTheme {\n /** root 要素に追加するクラス */\n className: string;\n}\n\nexport const THEMES: Record<ThemeName, ReactTheme> = {\n default: { className: \"calendar-theme-default\" },\n modern: { className: \"calendar-theme-modern\" },\n minimal: { className: \"calendar-theme-minimal\" },\n rounded: { className: \"calendar-theme-rounded\" },\n retro: { className: \"calendar-theme-retro\" },\n};\n\nexport function resolveTheme(theme?: ThemeName | ReactTheme): ReactTheme {\n if (theme === undefined) return THEMES.default;\n if (typeof theme === \"string\") return THEMES[theme] ?? THEMES.default;\n return theme;\n}\n\n// ─── カラースキーム ───────────────────────────────────────\n\n/** 組み込みカラースキーム名。カスタムは CSS 変数マップを直接渡せる */\nexport type ColorSchemeName =\n | \"default\"\n | \"ocean\"\n | \"forest\"\n | \"sunset\"\n | \"mono\"\n | \"midnight\"\n | \"blossom\";\n\n/** CSS カスタムプロパティ(--cal-*)の値マップ */\nexport type ReactColorScheme = Record<`--cal-${string}`, string>;\n\n/** 各カラースキームで定義する CSS 変数(SCHEME_VALUES の並び順の定義) */\nconst SCHEME_KEYS = [\n \"--cal-bg\",\n \"--cal-fg\",\n \"--cal-accent\",\n \"--cal-weekend-fg\",\n \"--cal-border\",\n \"--cal-header-bg\",\n \"--cal-highlight-bg\",\n \"--cal-highlight-fg\",\n \"--cal-range-bg\",\n \"--cal-today-bg\",\n \"--cal-today-fg\",\n] as const;\n\n/** カラースキームごとの値を SCHEME_KEYS の並びで定義する */\nconst SCHEME_VALUES: Record<ColorSchemeName, readonly string[]> = {\n default: [\n \"#ffffff\",\n \"#1e293b\",\n \"#dc2626\",\n \"#94a3b8\",\n \"#e2e8f0\",\n \"#f8fafc\",\n \"#dc2626\",\n \"#ffffff\",\n \"#fef3c7\",\n \"#fff7ed\",\n \"#c2410c\",\n ],\n ocean: [\n \"#f0f9ff\",\n \"#0f172a\",\n \"#0e7490\",\n \"#7dd3fc\",\n \"#bae6fd\",\n \"#e0f2fe\",\n \"#0e7490\",\n \"#ffffff\",\n \"#dff3fe\",\n \"#cffafe\",\n \"#155e75\",\n ],\n forest: [\n \"#f0fdf4\",\n \"#052e16\",\n \"#15803d\",\n \"#86efac\",\n \"#bbf7d0\",\n \"#dcfce7\",\n \"#15803d\",\n \"#ffffff\",\n \"#dcfce7\",\n \"#f0fdf4\",\n \"#166534\",\n ],\n sunset: [\n \"#fffaf5\",\n \"#431407\",\n \"#ea580c\",\n \"#fdba74\",\n \"#fed7aa\",\n \"#ffedd5\",\n \"#ea580c\",\n \"#ffffff\",\n \"#ffedd5\",\n \"#fff7ed\",\n \"#9a3412\",\n ],\n mono: [\n \"#ffffff\",\n \"#111827\",\n \"#374151\",\n \"#d1d5db\",\n \"#e5e7eb\",\n \"#f3f4f6\",\n \"#111827\",\n \"#ffffff\",\n \"#f3f4f6\",\n \"#e5e7eb\",\n \"#111827\",\n ],\n midnight: [\n \"#0f172a\",\n \"#e2e8f0\",\n \"#38bdf8\",\n \"#475569\",\n \"#1e293b\",\n \"#1e293b\",\n \"#38bdf8\",\n \"#0f172a\",\n \"#0c4a6e\",\n \"#0c4a6e\",\n \"#7dd3fc\",\n ],\n blossom: [\n \"#fffaff\",\n \"#500724\",\n \"#db2777\",\n \"#f9a8d4\",\n \"#fbcfe8\",\n \"#fdf2f8\",\n \"#db2777\",\n \"#ffffff\",\n \"#fce7f3\",\n \"#fdf2f8\",\n \"#be185d\",\n ],\n};\n\nexport const COLOR_SCHEMES: Record<ColorSchemeName, ReactColorScheme> =\n Object.fromEntries(\n Object.entries(SCHEME_VALUES).map(([name, values]) => [\n name,\n Object.fromEntries(SCHEME_KEYS.map((key, i) => [key, values[i]!])),\n ]),\n ) as Record<ColorSchemeName, ReactColorScheme>;\n\nexport function resolveColorScheme(\n scheme?: ColorSchemeName | ReactColorScheme,\n): ReactColorScheme {\n if (scheme === undefined) return COLOR_SCHEMES.default;\n if (typeof scheme === \"string\") {\n return COLOR_SCHEMES[scheme] ?? COLOR_SCHEMES.default;\n }\n return scheme;\n}\n","import type {\n CalendarState,\n CalendarStateOptions,\n Direction,\n MonthDirection,\n} from \"@typescript-calendar-lib/tui\";\nimport {\n buildMonthData,\n clearSelection,\n createCalendarState,\n getCursorDate,\n getSelectedDate,\n goToToday,\n moveCursor,\n navigateMonth,\n rebuildState,\n resolveOptions,\n selectDate,\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\"\n > {\n initialYear?: number;\n initialMonth?: number;\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 goToday: () => void;\n /** カーソル位置の日付を選択 */\n selectDate: () => void;\n /** 選択を解除 */\n clearSelection: () => void;\n /** カーソル位置の日付(null の場合あり) */\n cursorDate: Date | null;\n /** 選択済み日付(null の場合あり) */\n selectedDate: Date | null;\n}\n\n/** undefined を含む日付を値(時刻)で比較する */\nfunction sameDateValue(a: Date | undefined, b: Date | undefined): boolean {\n return (a?.getTime() ?? -1) === (b?.getTime() ?? -1);\n}\n\n/** オプションの「値」が等しいか比較する(Date は getTime、参照ではない) */\nfunction sameOptionsValue(\n a: UseCalendarStateOptions,\n b: UseCalendarStateOptions,\n): boolean {\n return (\n a.initialYear === b.initialYear &&\n a.initialMonth === b.initialMonth &&\n a.locale === b.locale &&\n a.weekStart === b.weekStart &&\n sameDateValue(a.today, b.today) &&\n sameDateValue(a.highlight, b.highlight) &&\n sameDateValue(a.range?.from, b.range?.from) &&\n sameDateValue(a.range?.to, b.range?.to)\n );\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({\n initialYear: options.initialYear,\n initialMonth: options.initialMonth,\n today: options.today,\n locale: options.locale,\n weekStart: options.weekStart,\n highlight: options.highlight,\n range: options.range,\n }),\n );\n\n // options の「値の変化」を検知して状態を再構築する。\n // 初回は prevOptions が同一なので何もしない。値が同じままの再レンダリング\n // でも何もしないため、インラインリテラルを毎回渡しても無限ループしない。\n const prevOptions = useRef(options);\n useEffect(() => {\n if (sameOptionsValue(prevOptions.current, options)) return;\n // initialYear/initialMonth は「初期値」。値が実際に変わった時だけ適用し、\n // 変わっていない場合はナビゲーション後の現在位置 (prev.year/month) を維持する\n // (options 変更で表示月が初期値に引き戻されるのを防ぐ)。\n const prevInitialYear = prevOptions.current.initialYear;\n const prevInitialMonth = prevOptions.current.initialMonth;\n prevOptions.current = options;\n setState((prev) => {\n const resolved = resolveOptions({\n // today が省略されたら前回の値を引き継ぐ(状態に固定された今日を維持)\n today: options.today ?? prev.options.today,\n locale: options.locale ?? prev.options.locale,\n weekStart: options.weekStart ?? prev.options.weekStart,\n highlight: options.highlight,\n range: options.range,\n });\n const year =\n options.initialYear !== undefined &&\n options.initialYear !== prevInitialYear\n ? options.initialYear\n : prev.year;\n const month =\n options.initialMonth !== undefined &&\n options.initialMonth !== prevInitialMonth\n ? options.initialMonth\n : prev.month;\n // 範囲外の month は rebuildState 側で正規化される(state と monthData の乖離を防ぐ)\n const monthData = buildMonthData(year, month, resolved);\n return rebuildState(\n year,\n month,\n prev.cursor,\n prev.selectedDate,\n resolved,\n monthData,\n );\n });\n }, [options]);\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 goToday: useCallback(() => setState((prev) => goToToday(prev)), []),\n selectDate: useCallback(() => setState((prev) => selectDate(prev)), []),\n clearSelection: useCallback(\n () => setState((prev) => clearSelection(prev)),\n [],\n ),\n cursorDate: getCursorDate(state),\n selectedDate: getSelectedDate(state),\n };\n}\n\nexport type { Direction, MonthDirection };\n","import type { CalendarOptions } from \"@typescript-calendar-lib/core\";\nimport {\n buildMonthGrid,\n createDate,\n getMonthName,\n getWeekdayHeaders,\n} from \"@typescript-calendar-lib/core\";\nimport type { CSSProperties } 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\";\nimport \"./calendar.css\";\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 /** 見た目テーマ。既定は \"default\" */\n theme?: ThemeName | ReactTheme;\n /** カラースキーム。既定は \"default\" */\n colorScheme?: ColorSchemeName | ReactColorScheme;\n /** セルサイズ。既定は \"md\"。{ width, height } で自由に指定できる */\n size?: CalendarSize;\n /** root 要素に追加するスタイル。CSS変数(--cal-*)で自由に上書きできる */\n style?: CSSProperties;\n\n // ── インタラクション ──\n\n /** インタラクティブモードを有効にする。セルクリック・ホバー・キーボード選択が可能になる */\n interactive?: boolean;\n /** セルクリック時のコールバック */\n onDateClick?: (date: Date) => void;\n /** セルホバー時のコールバック */\n onDateHover?: (date: Date) => void;\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 style,\n interactive = false,\n onDateClick,\n onDateHover,\n}: CalendarProps) {\n const cellDate = (day: number): Date => createDate(year, month - 1, day);\n const cellClass = (day: number): string | undefined =>\n getCellClasses(cellDate(day), { today, highlight, range }) || undefined;\n\n const handleCellClick = (day: number) => {\n if (interactive && onDateClick) onDateClick(cellDate(day));\n };\n\n const handleCellHover = (day: number) => {\n if (interactive && onDateHover) onDateHover(cellDate(day));\n };\n\n return (\n <div\n className={`calendar ${resolveTheme(theme).className}${isSizeName(size) ? ` calendar-size-${size}` : \"\"}${interactive ? \" calendar-interactive\" : \"\"}`}\n style={{\n ...(resolveColorScheme(colorScheme) as CSSProperties),\n ...buildSizeStyle(size),\n ...style,\n }}\n >\n <div className=\"calendar-header\">\n <h2>\n {getMonthName(locale, month)} {year}\n </h2>\n </div>\n <table>\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} />;\n return (\n <td key={day} className={cellClass(day)}>\n {interactive ? (\n <button\n type=\"button\"\n className=\"calendar-day-btn\"\n onClick={() => handleCellClick(day)}\n onMouseEnter={() => handleCellHover(day)}\n tabIndex={0}\n aria-label={`${getMonthName(locale, month)} ${day}, ${year}`}\n >\n {day}\n </button>\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\nexport type {\n UseCalendarStateOptions,\n UseCalendarStateReturn,\n} from \"./hooks.ts\";\nexport { useCalendarState } from \"./hooks.ts\";\nexport type {\n ColorSchemeName,\n ReactColorScheme,\n ReactTheme,\n ThemeName,\n} from \"./themes.ts\";\nexport {\n COLOR_SCHEMES,\n resolveColorScheme,\n resolveTheme,\n THEMES,\n} from \"./themes.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AM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAiGA,MAAa,gBACX,OAAO,YACL,OAAO,QAAQ;CA/FjB,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AAKiB,CAAa,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY,CACpD,MACA,OAAO,YAAY,YAAY,KAAK,KAAK,MAAM,CAAC,KAAK,OAAO,EAAG,CAAC,CAAC,CACnE,CAAC,CACH;AAEF,SAAgB,mBACd,QACkB;CAClB,IAAI,WAAW,KAAA,GAAW,OAAO,cAAc;CAC/C,IAAI,OAAO,WAAW,UACpB,OAAO,cAAc,WAAW,cAAc;CAEhD,OAAO;AACT;;;;ACnHA,SAAS,cAAc,GAAqB,GAA8B;CACxE,QAAQ,GAAG,QAAQ,KAAK,SAAS,GAAG,QAAQ,KAAK;AACnD;;AAGA,SAAS,iBACP,GACA,GACS;CACT,OACE,EAAE,gBAAgB,EAAE,eACpB,EAAE,iBAAiB,EAAE,gBACrB,EAAE,WAAW,EAAE,UACf,EAAE,cAAc,EAAE,aAClB,cAAc,EAAE,OAAO,EAAE,KAAK,KAC9B,cAAc,EAAE,WAAW,EAAE,SAAS,KACtC,cAAc,EAAE,OAAO,MAAM,EAAE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AA,UAAe,IAAQ,GAAd,GAAc,CACxB,EACC,CAAA,EACC,CAAA,GACP,oBAAC,SAAD,EAAA,UACG,eAAe,MAAM,OAAO,SAAS,CAAC,CAAC,KAAK,KAAK,MAAM;GACtD,IAAI,IAAI,OAAO,MAAM,MAAM,IAAI,GAAG,OAAO;GACzC,OAEE,oBAAC,MAAD,EAAA,UACG,IAAI,KAAK,KAAK,MAAM;IACnB,IAAI,QAAQ,MAEV,OAAO,oBAAC,MAAD,CAAa,GAAJ,CAAI;IACtB,OACE,oBAAC,MAAD;KAAc,WAAW,UAAU,GAAG;KACnC,UAAA,cACC,oBAAC,UAAD;MACE,MAAK;MACL,WAAU;MACV,eAAe,gBAAgB,GAAG;MAClC,oBAAoB,gBAAgB,GAAG;MACvC,UAAU;MACV,cAAY,GAAG,aAAa,QAAQ,KAAK,EAAE,GAAG,IAAI,IAAI;MAErD,UAAA;KACK,CAAA,IAER;IAEA,GAfK,GAeL;GAER,CAAC,EACC,GAxBK,CAwBL;EAER,CAAC,EACI,CAAA,CACF,EAAA,CAAA,CACJ;;AAET"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/cell-classes.ts","../src/size.ts","../src/themes.ts","../src/Calendar.tsx","../src/hooks.ts","../src/interactive.tsx"],"sourcesContent":["import {\n type CalendarCellState,\n getCalendarCellState,\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}\n\n// 範囲の from > to は不正入力として RangeError(isDateInRange が検証する)\n\n/** セル状態に応じた CSS クラスを組み立てる */\nexport function stateToClasses(state: CalendarCellState): string {\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 return classes.join(\" \");\n}\n\n/** 日付セルの状態(週末・今日・ハイライト・範囲)に応じたCSSクラスを組み立てる */\nexport function getCellClasses(date: Date, options: CellStateOptions): string {\n return stateToClasses(getCalendarCellState(date, options));\n}\n","import type { CSSProperties } from \"react\";\n\n// ─── セルサイズ ───────────────────────────────────────────\n\n/** 組み込みサイズ名 */\nexport type CalendarSizeName = \"sm\" | \"md\" | \"lg\";\n\n/** カスタムセルサイズ。数値は px、文字列は CSS 長さのまま渡す */\nexport interface CalendarCustomSize {\n width?: number | string;\n height?: number | string;\n}\n\n/** セルサイズ指定 */\nexport type CalendarSize = CalendarSizeName | CalendarCustomSize;\n\n/** 組み込みサイズ名のみ真を返す(未知の文字列はカスタムサイズとして扱わない) */\nexport function isSizeName(size: CalendarSize): size is CalendarSizeName {\n return typeof size === \"string\" && [\"sm\", \"md\", \"lg\"].includes(size);\n}\n\nfunction toCssLength(value: number | string): string {\n return typeof value === \"number\" ? `${value}px` : value;\n}\n\nexport function buildSizeStyle(size: CalendarSize): CSSProperties {\n if (isSizeName(size)) return {};\n const style: Record<string, string> = {};\n if (size.width !== undefined) style[\"--cal-cell-w\"] = toCssLength(size.width);\n if (size.height !== undefined)\n style[\"--cal-cell-h\"] = toCssLength(size.height);\n return style;\n}\n","// ─── テーマ ───────────────────────────────────────────────\n\n/** 組み込みテーマ名。カスタムテーマは ReactTheme オブジェクトを直接渡せる */\nexport type ThemeName = \"default\" | \"modern\" | \"minimal\" | \"rounded\" | \"retro\";\n\n/** React の見た目定義。テーマは主に CSS クラスで切り替える */\nexport interface ReactTheme {\n /** root 要素に追加するクラス */\n className: string;\n}\n\nexport const THEMES: Record<ThemeName, ReactTheme> = {\n default: { className: \"calendar-theme-default\" },\n modern: { className: \"calendar-theme-modern\" },\n minimal: { className: \"calendar-theme-minimal\" },\n rounded: { className: \"calendar-theme-rounded\" },\n retro: { className: \"calendar-theme-retro\" },\n};\n\nexport function resolveTheme(theme?: ThemeName | ReactTheme): ReactTheme {\n if (theme === undefined) return THEMES.default;\n if (typeof theme === \"string\") return THEMES[theme] ?? THEMES.default;\n return theme;\n}\n\n// ─── カラースキーム ───────────────────────────────────────\n\n/** 組み込みカラースキーム名。カスタムは CSS 変数マップを直接渡せる */\nexport type ColorSchemeName =\n | \"default\"\n | \"ocean\"\n | \"forest\"\n | \"sunset\"\n | \"mono\"\n | \"midnight\"\n | \"blossom\";\n\n/** CSS カスタムプロパティ(--cal-*)の値マップ */\nexport type ReactColorScheme = Record<`--cal-${string}`, string>;\n\n/** 各カラースキームで定義する CSS 変数(SCHEME_VALUES の並び順の定義) */\nconst SCHEME_KEYS = [\n \"--cal-bg\",\n \"--cal-fg\",\n \"--cal-accent\",\n \"--cal-weekend-fg\",\n \"--cal-border\",\n \"--cal-header-bg\",\n \"--cal-highlight-bg\",\n \"--cal-highlight-fg\",\n \"--cal-range-bg\",\n \"--cal-today-bg\",\n \"--cal-today-fg\",\n] as const;\n\n/** カラースキームごとの値を SCHEME_KEYS の並びで定義する */\nconst SCHEME_VALUES: Record<ColorSchemeName, readonly string[]> = {\n default: [\n \"#ffffff\",\n \"#1e293b\",\n \"#dc2626\",\n \"#94a3b8\",\n \"#e2e8f0\",\n \"#f8fafc\",\n \"#dc2626\",\n \"#ffffff\",\n \"#fef3c7\",\n \"#fff7ed\",\n \"#c2410c\",\n ],\n ocean: [\n \"#f0f9ff\",\n \"#0f172a\",\n \"#0e7490\",\n \"#7dd3fc\",\n \"#bae6fd\",\n \"#e0f2fe\",\n \"#0e7490\",\n \"#ffffff\",\n \"#dff3fe\",\n \"#cffafe\",\n \"#155e75\",\n ],\n forest: [\n \"#f0fdf4\",\n \"#052e16\",\n \"#15803d\",\n \"#86efac\",\n \"#bbf7d0\",\n \"#dcfce7\",\n \"#15803d\",\n \"#ffffff\",\n \"#dcfce7\",\n \"#f0fdf4\",\n \"#166534\",\n ],\n sunset: [\n \"#fffaf5\",\n \"#431407\",\n \"#ea580c\",\n \"#fdba74\",\n \"#fed7aa\",\n \"#ffedd5\",\n \"#ea580c\",\n \"#ffffff\",\n \"#ffedd5\",\n \"#fff7ed\",\n \"#9a3412\",\n ],\n mono: [\n \"#ffffff\",\n \"#111827\",\n \"#374151\",\n \"#d1d5db\",\n \"#e5e7eb\",\n \"#f3f4f6\",\n \"#111827\",\n \"#ffffff\",\n \"#f3f4f6\",\n \"#e5e7eb\",\n \"#111827\",\n ],\n midnight: [\n \"#0f172a\",\n \"#e2e8f0\",\n \"#38bdf8\",\n \"#475569\",\n \"#1e293b\",\n \"#1e293b\",\n \"#38bdf8\",\n \"#0f172a\",\n \"#0c4a6e\",\n \"#0c4a6e\",\n \"#7dd3fc\",\n ],\n blossom: [\n \"#fffaff\",\n \"#500724\",\n \"#db2777\",\n \"#f9a8d4\",\n \"#fbcfe8\",\n \"#fdf2f8\",\n \"#db2777\",\n \"#ffffff\",\n \"#fce7f3\",\n \"#fdf2f8\",\n \"#be185d\",\n ],\n};\n\nexport const COLOR_SCHEMES: Record<ColorSchemeName, ReactColorScheme> =\n Object.fromEntries(\n Object.entries(SCHEME_VALUES).map(([name, values]) => [\n name,\n Object.fromEntries(SCHEME_KEYS.map((key, i) => [key, values[i]!])),\n ]),\n ) as Record<ColorSchemeName, ReactColorScheme>;\n\nexport function resolveColorScheme(\n scheme?: ColorSchemeName | ReactColorScheme,\n): ReactColorScheme {\n if (scheme === undefined) return COLOR_SCHEMES.default;\n if (typeof scheme === \"string\") {\n return COLOR_SCHEMES[scheme] ?? COLOR_SCHEMES.default;\n }\n return scheme;\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 type {\n CSSProperties,\n KeyboardEvent as ReactKeyboardEvent,\n ReactNode,\n Ref,\n} from \"react\";\nimport { stateToClasses } 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\";\nimport \"./calendar.css\";\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 /** 見た目テーマ。既定は \"default\" */\n theme?: ThemeName | ReactTheme;\n /** カラースキーム。既定は \"default\" */\n colorScheme?: ColorSchemeName | ReactColorScheme;\n /** セルサイズ。既定は \"md\"。{ width, height } で自由に指定できる */\n size?: CalendarSize;\n /** root 要素に追加するスタイル。CSS変数(--cal-*)で自由に上書きできる */\n style?: CSSProperties;\n\n // ── インタラクション ──\n\n /** インタラクティブモードを有効にする。セルクリック・ホバー・キーボード選択が可能になる */\n interactive?: boolean;\n /** セルクリック時のコールバック */\n onDateClick?: (date: Date) => void;\n /** セルホバー時のコールバック */\n onDateHover?: (date: Date) => 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 /** セル内容のカスタムレンダリング。interactive 時は button の子として描画される */\n renderCell?: (day: number, date: Date, state: CalendarCellState) => ReactNode;\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 style,\n interactive = false,\n onDateClick,\n onDateHover,\n onKeyDown,\n selectedDate = null,\n cursorDate = null,\n renderCell,\n ref,\n}: CalendarProps) {\n const cellDate = (day: number): Date => createDate(year, month - 1, day);\n const cellState = (day: number): CalendarCellState =>\n getCalendarCellState(cellDate(day), { today, highlight, range });\n const cellClass = (day: number): string | undefined =>\n stateToClasses(cellState(day)) || undefined;\n const isSelected = (day: number): boolean =>\n selectedDate !== null && isSameDay(cellDate(day), selectedDate);\n const isCursor = (day: number): boolean =>\n cursorDate !== null && isSameDay(cellDate(day), cursorDate);\n\n const handleCellClick = (day: number) => {\n if (interactive && onDateClick) onDateClick(cellDate(day));\n };\n\n const handleCellHover = (day: number) => {\n if (interactive && onDateHover) onDateHover(cellDate(day));\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 <div\n ref={ref}\n className={`calendar ${resolveTheme(theme).className}${isSizeName(size) ? ` calendar-size-${size}` : \"\"}${interactive ? \" calendar-interactive\" : \"\"}`}\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 state = cellState(day);\n const selected = isSelected(day);\n const cursor = isCursor(day);\n return (\n // biome-ignore lint/a11y/useAriaPropsSupportedByRole: interactive 時は td に role=gridcell が付き aria-selected は有効(role が動的なため静的解析できない)\n <td\n key={day}\n role={cellRole}\n tabIndex={interactive ? -1 : undefined}\n className={cellClass(day)}\n aria-selected={selected || undefined}\n aria-current={state.isToday ? \"date\" : undefined}\n >\n {interactive ? (\n <button\n type=\"button\"\n className=\"calendar-day-btn\"\n onClick={() => handleCellClick(day)}\n onMouseEnter={() => handleCellHover(day)}\n tabIndex={cursor ? 0 : -1}\n data-cursor={cursor ? \"true\" : undefined}\n aria-label={`${getMonthName(locale, month)} ${day}, ${year}`}\n >\n {renderCell\n ? renderCell(day, cellDate(day), state)\n : day}\n </button>\n ) : renderCell ? (\n renderCell(day, cellDate(day), state)\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 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\"\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 clearSelection: () => void;\n /** カーソル位置の日付(null の場合あり) */\n cursorDate: Date | null;\n /** 選択済み日付(null の場合あり) */\n selectedDate: Date | null;\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({\n initialYear: options.initialYear,\n initialMonth: options.initialMonth,\n today: options.today,\n locale: options.locale,\n weekStart: options.weekStart,\n highlight: options.highlight,\n range: options.range,\n }),\n );\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 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 }\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 clearSelection: useCallback(\n () => setState((prev) => clearSelection(prev)),\n [],\n ),\n cursorDate: getCursorDate(state),\n selectedDate: getSelectedDate(state),\n };\n}\n\nexport type { Direction, MonthDirection };\n","import type { CalendarOptions } from \"@typescript-calendar-lib/core\";\nimport type { CSSProperties } from \"react\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { Calendar, type CalendarProps } from \"./Calendar.tsx\";\nimport { useCalendarState } from \"./hooks.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 /** 色付け範囲 */\n range?: { from: Date; to: Date };\n /** 今日の基準日。省略時は初回レンダリング時刻に解決される */\n today?: Date;\n /** 表示中の年月が変わったときに呼ばれる */\n onMonthChange?: (year: number, month: number) => void;\n\n // ── Calendar の見た目 ──\n\n theme?: ThemeName | ReactTheme;\n colorScheme?: ColorSchemeName | ReactColorScheme;\n size?: CalendarSize;\n style?: CSSProperties;\n /** セル内容のカスタムレンダリング */\n renderCell?: CalendarProps[\"renderCell\"];\n\n // ── イベント ──\n\n /** セルクリック時(キーボードの Enter/Space 含む) */\n onDateClick?: (date: Date) => void;\n /** セルホバー時 */\n onDateHover?: (date: Date) => void;\n}\n\n/**\n * `useCalendarState` と `Calendar` を一体化したインタラクティブカレンダー。\n * 内部で状態を管理し、矢印キー(カーソル移動)・PageUp/PageDown(月移動)の\n * キーボード操作に対応する。\n */\nexport function InteractiveCalendar(props: InteractiveCalendarProps) {\n const {\n initialYear,\n initialMonth,\n locale,\n weekStart,\n highlight,\n range,\n today,\n onMonthChange,\n theme,\n colorScheme,\n size,\n style,\n renderCell,\n onDateClick,\n onDateHover,\n } = props;\n\n const hook = useCalendarState({\n initialYear,\n initialMonth,\n locale,\n weekStart,\n today,\n highlight,\n range,\n onMonthChange,\n });\n\n const { state, moveCursor, goPrev, goNext } = hook;\n const rootRef = useRef<HTMLDivElement>(null);\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 switch (e.key) {\n case \"ArrowRight\":\n e.preventDefault();\n moveCursor(\"right\");\n break;\n case \"ArrowLeft\":\n e.preventDefault();\n moveCursor(\"left\");\n break;\n case \"ArrowDown\":\n e.preventDefault();\n moveCursor(\"down\");\n break;\n case \"ArrowUp\":\n e.preventDefault();\n moveCursor(\"up\");\n break;\n case \"PageUp\":\n e.preventDefault();\n goPrev();\n break;\n case \"PageDown\":\n e.preventDefault();\n goNext();\n break;\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 theme={theme}\n colorScheme={colorScheme}\n size={size}\n style={style}\n interactive\n renderCell={renderCell}\n selectedDate={hook.selectedDate}\n cursorDate={hook.cursorDate}\n onDateClick={onDateClick}\n onDateHover={onDateHover}\n onKeyDown={handleKeyDown}\n />\n );\n}\n"],"mappings":";;;;;;AAgBA,SAAgB,eAAe,OAAkC;CAC/D,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,OAAO,QAAQ,KAAK,GAAG;AACzB;;;;ACNA,SAAgB,WAAW,MAA8C;CACvE,OAAO,OAAO,SAAS,YAAY;EAAC;EAAM;EAAM;CAAI,CAAC,CAAC,SAAS,IAAI;AACrE;AAEA,SAAS,YAAY,OAAgC;CACnD,OAAO,OAAO,UAAU,WAAW,GAAG,MAAM,MAAM;AACpD;AAEA,SAAgB,eAAe,MAAmC;CAChE,IAAI,WAAW,IAAI,GAAG,OAAO,CAAC;CAC9B,MAAM,QAAgC,CAAC;CACvC,IAAI,KAAK,UAAU,KAAA,GAAW,MAAM,kBAAkB,YAAY,KAAK,KAAK;CAC5E,IAAI,KAAK,WAAW,KAAA,GAClB,MAAM,kBAAkB,YAAY,KAAK,MAAM;CACjD,OAAO;AACT;;;ACrBA,MAAa,SAAwC;CACnD,SAAS,EAAE,WAAW,yBAAyB;CAC/C,QAAQ,EAAE,WAAW,wBAAwB;CAC7C,SAAS,EAAE,WAAW,yBAAyB;CAC/C,SAAS,EAAE,WAAW,yBAAyB;CAC/C,OAAO,EAAE,WAAW,uBAAuB;AAC7C;AAEA,SAAgB,aAAa,OAA4C;CACvE,IAAI,UAAU,KAAA,GAAW,OAAO,OAAO;CACvC,IAAI,OAAO,UAAU,UAAU,OAAO,OAAO,UAAU,OAAO;CAC9D,OAAO;AACT;;AAkBA,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAiGA,MAAa,gBACX,OAAO,YACL,OAAO,QAAQ;CA/FjB,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AAKiB,CAAa,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY,CACpD,MACA,OAAO,YAAY,YAAY,KAAK,KAAK,MAAM,CAAC,KAAK,OAAO,EAAG,CAAC,CAAC,CACnE,CAAC,CACH;AAEF,SAAgB,mBACd,QACkB;CAClB,IAAI,WAAW,KAAA,GAAW,OAAO,cAAc;CAC/C,IAAI,OAAO,WAAW,UACpB,OAAO,cAAc,WAAW,cAAc;CAEhD,OAAO;AACT;;;;ACtFA,SAAgB,SAAS,EACvB,MACA,OACA,SAAS,MACT,YAAY,UACZ,WACA,OACA,OACA,QAAQ,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O,MAAM,QAAQ;EACd;EACM;EACP;EACC;EACP,aAAA;EACY;EACZ,cAAc,KAAK;EACnB,YAAY,KAAK;EACJ;EACA;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.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@typescript-calendar-lib/core": "0.
|
|
24
|
-
"@typescript-calendar-lib/tui": "0.
|
|
23
|
+
"@typescript-calendar-lib/core": "0.4.1",
|
|
24
|
+
"@typescript-calendar-lib/tui": "0.4.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@testing-library/react": "^16",
|