@typescript-calendar-lib/react 0.1.1 → 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/LICENSE +21 -0
- package/README.md +344 -0
- package/{src → dist}/calendar.css +40 -73
- package/dist/index.d.ts +158 -0
- package/dist/index.js +373 -0
- package/dist/index.js.map +1 -0
- package/package.json +23 -8
- package/src/cell-classes.ts +0 -22
- package/src/global.d.ts +0 -1
- package/src/hooks.ts +0 -107
- package/src/index.test.tsx +0 -217
- package/src/index.tsx +0 -174
- package/src/size.ts +0 -32
- package/src/themes.ts +0 -143
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
//#region src/size.d.ts
|
|
5
|
+
/** 組み込みサイズ名 */
|
|
6
|
+
type CalendarSizeName = "sm" | "md" | "lg";
|
|
7
|
+
/** カスタムセルサイズ。数値は px、文字列は CSS 長さのまま渡す */
|
|
8
|
+
interface CalendarCustomSize {
|
|
9
|
+
width?: number | string;
|
|
10
|
+
height?: number | string;
|
|
11
|
+
}
|
|
12
|
+
/** セルサイズ指定 */
|
|
13
|
+
type CalendarSize = CalendarSizeName | CalendarCustomSize;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/themes.d.ts
|
|
16
|
+
/** 組み込みテーマ名。カスタムテーマは ReactTheme オブジェクトを直接渡せる */
|
|
17
|
+
type ThemeName = "default" | "modern" | "minimal" | "rounded" | "retro";
|
|
18
|
+
/** React の見た目定義。テーマは主に CSS クラスで切り替える */
|
|
19
|
+
interface ReactTheme {
|
|
20
|
+
/** root 要素に追加するクラス */
|
|
21
|
+
className: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const THEMES: Record<ThemeName, ReactTheme>;
|
|
24
|
+
export declare function resolveTheme(theme?: ThemeName | ReactTheme): ReactTheme;
|
|
25
|
+
/** 組み込みカラースキーム名。カスタムは CSS 変数マップを直接渡せる */
|
|
26
|
+
type ColorSchemeName = "default" | "ocean" | "forest" | "sunset" | "mono" | "midnight" | "blossom";
|
|
27
|
+
/** CSS カスタムプロパティ(--cal-*)の値マップ */
|
|
28
|
+
type ReactColorScheme = Record<`--cal-${string}`, string>;
|
|
29
|
+
export declare const COLOR_SCHEMES: Record<ColorSchemeName, ReactColorScheme>;
|
|
30
|
+
export declare function resolveColorScheme(scheme?: ColorSchemeName | ReactColorScheme): ReactColorScheme;
|
|
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
|
|
74
|
+
//#region src/hooks.d.ts
|
|
75
|
+
interface UseCalendarStateOptions extends Pick<CalendarStateOptions, "locale" | "weekStart" | "today" | "highlight" | "range"> {
|
|
76
|
+
initialYear?: number;
|
|
77
|
+
initialMonth?: number;
|
|
78
|
+
/** 表示中の年月が変わったときに呼ばれる */
|
|
79
|
+
onMonthChange?: (year: number, month: number) => void;
|
|
80
|
+
}
|
|
81
|
+
interface UseCalendarStateReturn {
|
|
82
|
+
/** 現在のカレンダー状態 */
|
|
83
|
+
state: CalendarState;
|
|
84
|
+
/** カーソルを指定方向に移動 (wrap around) */
|
|
85
|
+
moveCursor: (direction: Direction) => void;
|
|
86
|
+
/** 前月/翌月へ移動 */
|
|
87
|
+
goNext: () => void;
|
|
88
|
+
goPrev: () => void;
|
|
89
|
+
/** 前年/翌年へ移動 */
|
|
90
|
+
navigateYear: (direction: MonthDirection) => void;
|
|
91
|
+
/** 指定した年月へジャンプ */
|
|
92
|
+
goToMonth: (year: number, month: number) => void;
|
|
93
|
+
/** 指定した日付の月へジャンプし、カーソルをその日付に置く */
|
|
94
|
+
goToDate: (date: Date) => void;
|
|
95
|
+
/** 今日の月へジャンプ */
|
|
96
|
+
goToday: () => void;
|
|
97
|
+
/** カーソル位置の日付を選択 */
|
|
98
|
+
selectDate: () => void;
|
|
99
|
+
/** 選択を解除 */
|
|
100
|
+
clearSelection: () => void;
|
|
101
|
+
/** カーソル位置の日付(null の場合あり) */
|
|
102
|
+
cursorDate: Date | null;
|
|
103
|
+
/** 選択済み日付(null の場合あり) */
|
|
104
|
+
selectedDate: Date | null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* tui の不変状態マシンを包む React hook。
|
|
108
|
+
* カレンダーのインタラクティブ操作をシンプルに利用できる。
|
|
109
|
+
*
|
|
110
|
+
* `options` の値(locale / weekStart / today / highlight / range /
|
|
111
|
+
* initialYear / initialMonth)が変わると、カーソル・選択を保ったまま
|
|
112
|
+
* 状態が再構築される。比較は値(Date は getTime)で行うため、インラインで
|
|
113
|
+
* オプションを渡しても値が同じなら再構築されない。
|
|
114
|
+
*
|
|
115
|
+
* `today` を省略した場合、最初に解決された値が状態に固定され、以降も
|
|
116
|
+
* 引き継がれる(毎レンダリング `new Date()` を渡さなくてよい)。
|
|
117
|
+
*/
|
|
118
|
+
export declare function useCalendarState(options?: UseCalendarStateOptions): UseCalendarStateReturn;
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/interactive.d.ts
|
|
121
|
+
interface InteractiveCalendarProps {
|
|
122
|
+
/** 表示開始年。既定は today の年 */
|
|
123
|
+
initialYear?: number;
|
|
124
|
+
/** 表示開始月 (1-12)。範囲外は正規化される */
|
|
125
|
+
initialMonth?: number;
|
|
126
|
+
locale?: CalendarOptions["locale"];
|
|
127
|
+
weekStart?: CalendarOptions["weekStart"];
|
|
128
|
+
/** ハイライト対象日 */
|
|
129
|
+
highlight?: Date;
|
|
130
|
+
/** 色付け範囲 */
|
|
131
|
+
range?: {
|
|
132
|
+
from: Date;
|
|
133
|
+
to: Date;
|
|
134
|
+
};
|
|
135
|
+
/** 今日の基準日。省略時は初回レンダリング時刻に解決される */
|
|
136
|
+
today?: Date;
|
|
137
|
+
/** 表示中の年月が変わったときに呼ばれる */
|
|
138
|
+
onMonthChange?: (year: number, month: number) => void;
|
|
139
|
+
theme?: ThemeName | ReactTheme;
|
|
140
|
+
colorScheme?: ColorSchemeName | ReactColorScheme;
|
|
141
|
+
size?: CalendarSize;
|
|
142
|
+
style?: CSSProperties;
|
|
143
|
+
/** セル内容のカスタムレンダリング */
|
|
144
|
+
renderCell?: CalendarProps["renderCell"];
|
|
145
|
+
/** セルクリック時(キーボードの Enter/Space 含む) */
|
|
146
|
+
onDateClick?: (date: Date) => void;
|
|
147
|
+
/** セルホバー時 */
|
|
148
|
+
onDateHover?: (date: Date) => void;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* `useCalendarState` と `Calendar` を一体化したインタラクティブカレンダー。
|
|
152
|
+
* 内部で状態を管理し、矢印キー(カーソル移動)・PageUp/PageDown(月移動)の
|
|
153
|
+
* キーボード操作に対応する。
|
|
154
|
+
*/
|
|
155
|
+
export declare function InteractiveCalendar(props: InteractiveCalendarProps): import("react").JSX.Element;
|
|
156
|
+
//#endregion
|
|
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 };
|
|
158
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { buildMonthGrid, createDate, getCalendarCellState, getMonthName, getWeekdayHeaders, isSameDay } from "@typescript-calendar-lib/core";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { clearSelection, createCalendarState, getCursorDate, getSelectedDate, goToDate, goToMonth, goToToday, moveCursor, navigateMonth, navigateYear, sameStateOptions, selectDate, updateStateOptions } from "@typescript-calendar-lib/tui";
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
5
|
+
//#region src/cell-classes.ts
|
|
6
|
+
/** セル状態に応じた CSS クラスを組み立てる */
|
|
7
|
+
function stateToClasses(state) {
|
|
8
|
+
const classes = [];
|
|
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");
|
|
13
|
+
return classes.join(" ");
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/size.ts
|
|
17
|
+
/** 組み込みサイズ名のみ真を返す(未知の文字列はカスタムサイズとして扱わない) */
|
|
18
|
+
function isSizeName(size) {
|
|
19
|
+
return typeof size === "string" && [
|
|
20
|
+
"sm",
|
|
21
|
+
"md",
|
|
22
|
+
"lg"
|
|
23
|
+
].includes(size);
|
|
24
|
+
}
|
|
25
|
+
function toCssLength(value) {
|
|
26
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
27
|
+
}
|
|
28
|
+
function buildSizeStyle(size) {
|
|
29
|
+
if (isSizeName(size)) return {};
|
|
30
|
+
const style = {};
|
|
31
|
+
if (size.width !== void 0) style["--cal-cell-w"] = toCssLength(size.width);
|
|
32
|
+
if (size.height !== void 0) style["--cal-cell-h"] = toCssLength(size.height);
|
|
33
|
+
return style;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/themes.ts
|
|
37
|
+
const THEMES = {
|
|
38
|
+
default: { className: "calendar-theme-default" },
|
|
39
|
+
modern: { className: "calendar-theme-modern" },
|
|
40
|
+
minimal: { className: "calendar-theme-minimal" },
|
|
41
|
+
rounded: { className: "calendar-theme-rounded" },
|
|
42
|
+
retro: { className: "calendar-theme-retro" }
|
|
43
|
+
};
|
|
44
|
+
function resolveTheme(theme) {
|
|
45
|
+
if (theme === void 0) return THEMES.default;
|
|
46
|
+
if (typeof theme === "string") return THEMES[theme] ?? THEMES.default;
|
|
47
|
+
return theme;
|
|
48
|
+
}
|
|
49
|
+
/** 各カラースキームで定義する CSS 変数(SCHEME_VALUES の並び順の定義) */
|
|
50
|
+
const SCHEME_KEYS = [
|
|
51
|
+
"--cal-bg",
|
|
52
|
+
"--cal-fg",
|
|
53
|
+
"--cal-accent",
|
|
54
|
+
"--cal-weekend-fg",
|
|
55
|
+
"--cal-border",
|
|
56
|
+
"--cal-header-bg",
|
|
57
|
+
"--cal-highlight-bg",
|
|
58
|
+
"--cal-highlight-fg",
|
|
59
|
+
"--cal-range-bg",
|
|
60
|
+
"--cal-today-bg",
|
|
61
|
+
"--cal-today-fg"
|
|
62
|
+
];
|
|
63
|
+
const COLOR_SCHEMES = Object.fromEntries(Object.entries({
|
|
64
|
+
default: [
|
|
65
|
+
"#ffffff",
|
|
66
|
+
"#1e293b",
|
|
67
|
+
"#dc2626",
|
|
68
|
+
"#94a3b8",
|
|
69
|
+
"#e2e8f0",
|
|
70
|
+
"#f8fafc",
|
|
71
|
+
"#dc2626",
|
|
72
|
+
"#ffffff",
|
|
73
|
+
"#fef3c7",
|
|
74
|
+
"#fff7ed",
|
|
75
|
+
"#c2410c"
|
|
76
|
+
],
|
|
77
|
+
ocean: [
|
|
78
|
+
"#f0f9ff",
|
|
79
|
+
"#0f172a",
|
|
80
|
+
"#0e7490",
|
|
81
|
+
"#7dd3fc",
|
|
82
|
+
"#bae6fd",
|
|
83
|
+
"#e0f2fe",
|
|
84
|
+
"#0e7490",
|
|
85
|
+
"#ffffff",
|
|
86
|
+
"#dff3fe",
|
|
87
|
+
"#cffafe",
|
|
88
|
+
"#155e75"
|
|
89
|
+
],
|
|
90
|
+
forest: [
|
|
91
|
+
"#f0fdf4",
|
|
92
|
+
"#052e16",
|
|
93
|
+
"#15803d",
|
|
94
|
+
"#86efac",
|
|
95
|
+
"#bbf7d0",
|
|
96
|
+
"#dcfce7",
|
|
97
|
+
"#15803d",
|
|
98
|
+
"#ffffff",
|
|
99
|
+
"#dcfce7",
|
|
100
|
+
"#f0fdf4",
|
|
101
|
+
"#166534"
|
|
102
|
+
],
|
|
103
|
+
sunset: [
|
|
104
|
+
"#fffaf5",
|
|
105
|
+
"#431407",
|
|
106
|
+
"#ea580c",
|
|
107
|
+
"#fdba74",
|
|
108
|
+
"#fed7aa",
|
|
109
|
+
"#ffedd5",
|
|
110
|
+
"#ea580c",
|
|
111
|
+
"#ffffff",
|
|
112
|
+
"#ffedd5",
|
|
113
|
+
"#fff7ed",
|
|
114
|
+
"#9a3412"
|
|
115
|
+
],
|
|
116
|
+
mono: [
|
|
117
|
+
"#ffffff",
|
|
118
|
+
"#111827",
|
|
119
|
+
"#374151",
|
|
120
|
+
"#d1d5db",
|
|
121
|
+
"#e5e7eb",
|
|
122
|
+
"#f3f4f6",
|
|
123
|
+
"#111827",
|
|
124
|
+
"#ffffff",
|
|
125
|
+
"#f3f4f6",
|
|
126
|
+
"#e5e7eb",
|
|
127
|
+
"#111827"
|
|
128
|
+
],
|
|
129
|
+
midnight: [
|
|
130
|
+
"#0f172a",
|
|
131
|
+
"#e2e8f0",
|
|
132
|
+
"#38bdf8",
|
|
133
|
+
"#475569",
|
|
134
|
+
"#1e293b",
|
|
135
|
+
"#1e293b",
|
|
136
|
+
"#38bdf8",
|
|
137
|
+
"#0f172a",
|
|
138
|
+
"#0c4a6e",
|
|
139
|
+
"#0c4a6e",
|
|
140
|
+
"#7dd3fc"
|
|
141
|
+
],
|
|
142
|
+
blossom: [
|
|
143
|
+
"#fffaff",
|
|
144
|
+
"#500724",
|
|
145
|
+
"#db2777",
|
|
146
|
+
"#f9a8d4",
|
|
147
|
+
"#fbcfe8",
|
|
148
|
+
"#fdf2f8",
|
|
149
|
+
"#db2777",
|
|
150
|
+
"#ffffff",
|
|
151
|
+
"#fce7f3",
|
|
152
|
+
"#fdf2f8",
|
|
153
|
+
"#be185d"
|
|
154
|
+
]
|
|
155
|
+
}).map(([name, values]) => [name, Object.fromEntries(SCHEME_KEYS.map((key, i) => [key, values[i]]))]));
|
|
156
|
+
function resolveColorScheme(scheme) {
|
|
157
|
+
if (scheme === void 0) return COLOR_SCHEMES.default;
|
|
158
|
+
if (typeof scheme === "string") return COLOR_SCHEMES[scheme] ?? COLOR_SCHEMES.default;
|
|
159
|
+
return scheme;
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
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
|
+
});
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/hooks.ts
|
|
229
|
+
/**
|
|
230
|
+
* tui の不変状態マシンを包む React hook。
|
|
231
|
+
* カレンダーのインタラクティブ操作をシンプルに利用できる。
|
|
232
|
+
*
|
|
233
|
+
* `options` の値(locale / weekStart / today / highlight / range /
|
|
234
|
+
* initialYear / initialMonth)が変わると、カーソル・選択を保ったまま
|
|
235
|
+
* 状態が再構築される。比較は値(Date は getTime)で行うため、インラインで
|
|
236
|
+
* オプションを渡しても値が同じなら再構築されない。
|
|
237
|
+
*
|
|
238
|
+
* `today` を省略した場合、最初に解決された値が状態に固定され、以降も
|
|
239
|
+
* 引き継がれる(毎レンダリング `new Date()` を渡さなくてよい)。
|
|
240
|
+
*/
|
|
241
|
+
function useCalendarState(options = {}) {
|
|
242
|
+
const [state, setState] = useState(() => createCalendarState({
|
|
243
|
+
initialYear: options.initialYear,
|
|
244
|
+
initialMonth: options.initialMonth,
|
|
245
|
+
today: options.today,
|
|
246
|
+
locale: options.locale,
|
|
247
|
+
weekStart: options.weekStart,
|
|
248
|
+
highlight: options.highlight,
|
|
249
|
+
range: options.range
|
|
250
|
+
}));
|
|
251
|
+
const prevOptions = useRef(options);
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
if (sameStateOptions(prevOptions.current, options)) return;
|
|
254
|
+
const previous = prevOptions.current;
|
|
255
|
+
prevOptions.current = options;
|
|
256
|
+
setState((current) => updateStateOptions(current, options, previous));
|
|
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]);
|
|
274
|
+
return {
|
|
275
|
+
state,
|
|
276
|
+
moveCursor: useCallback((direction) => setState((prev) => moveCursor(prev, direction)), []),
|
|
277
|
+
goNext: useCallback(() => setState((prev) => navigateMonth(prev, "next")), []),
|
|
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)), []),
|
|
282
|
+
goToday: useCallback(() => setState((prev) => goToToday(prev)), []),
|
|
283
|
+
selectDate: useCallback(() => setState((prev) => selectDate(prev)), []),
|
|
284
|
+
clearSelection: useCallback(() => setState((prev) => clearSelection(prev)), []),
|
|
285
|
+
cursorDate: getCursorDate(state),
|
|
286
|
+
selectedDate: getSelectedDate(state)
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
//#endregion
|
|
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,
|
|
303
|
+
today,
|
|
304
|
+
highlight,
|
|
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
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
371
|
+
export { COLOR_SCHEMES, Calendar, Calendar as default, InteractiveCalendar, THEMES, resolveColorScheme, resolveTheme, useCalendarState };
|
|
372
|
+
|
|
373
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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AAO,MAAM,QAAQ;EACrB,OAAO,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,25 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-calendar-lib/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/nazozokc/typescript-calendar-lib"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"development": "./src/index.tsx",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./calendar.css": "./dist/calendar.css"
|
|
18
|
+
},
|
|
7
19
|
"files": [
|
|
8
|
-
"
|
|
20
|
+
"dist"
|
|
9
21
|
],
|
|
10
22
|
"dependencies": {
|
|
11
|
-
"@typescript-calendar/core": "
|
|
12
|
-
"@typescript-calendar/tui": "
|
|
23
|
+
"@typescript-calendar-lib/core": "0.4.1",
|
|
24
|
+
"@typescript-calendar-lib/tui": "0.4.1"
|
|
13
25
|
},
|
|
14
26
|
"devDependencies": {
|
|
15
27
|
"@testing-library/react": "^16",
|
|
28
|
+
"@tsdown/css": "^0.23.0",
|
|
16
29
|
"@types/react": "^19",
|
|
17
30
|
"jsdom": "^26",
|
|
18
31
|
"react-dom": "19.2.8",
|
|
19
32
|
"vitest": "^5"
|
|
20
33
|
},
|
|
21
34
|
"peerDependencies": {
|
|
22
|
-
"typescript": "^5",
|
|
23
35
|
"react": "^19"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsdown"
|
|
24
39
|
}
|
|
25
|
-
}
|
|
40
|
+
}
|