@typescript-calendar-lib/react 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,18 +52,23 @@ export function App() {
52
52
  | `weekStart` | `"sunday" \| "monday"` | `"sunday"` | First day of the week |
53
53
  | `highlight` | `Date` | — | Date to highlight |
54
54
  | `range` | `{ from: Date; to: Date }` | — | Dates to emphasize |
55
+ | `rangePreview` | `{ from: Date; to: Date }` | — | Candidate range preview (hover preview), rendered with the `is-in-range-preview` class |
55
56
  | `today` | `Date` | — | Reference date for "today" styling |
56
57
  | `theme` | `ThemeName \| ReactTheme` | `"default"` | CSS class-based theme |
57
58
  | `colorScheme` | `ColorSchemeName \| ReactColorScheme` | `"default"` | CSS variable-based colors |
58
59
  | `size` | `CalendarSize` | `"md"` | Cell size |
60
+ | `responsive` | `boolean` | `false` | Shrink cells & padding below `480px` so the grid fits phone screens |
59
61
  | `style` | `CSSProperties` | — | Extra styles for the root element |
60
62
  | `interactive` | `boolean` | `false` | Enable cell click/hover/keyboard selection |
61
- | `onDateClick` | `(date: Date) => void` | — | Called when a day cell is clicked (or Enter/Space pressed) |
63
+ | `onDateClick` | `(date: Date, data?: unknown) => void` | — | Called when a day cell is clicked (or Enter/Space pressed); `data` is that cell's `cellData` value (`undefined` when none) |
62
64
  | `onDateHover` | `(date: Date) => void` | — | Called when a day cell is hovered |
65
+ | `onDateLeave` | `() => void` | — | Called when the mouse leaves the calendar |
63
66
  | `onKeyDown` | `(e: KeyboardEvent) => void` | — | Keyboard handler on the grid element |
64
67
  | `selectedDate` | `Date \| null` | `null` | Marks the cell `aria-selected` |
65
68
  | `cursorDate` | `Date \| null` | `null` | The cell that gets `tabIndex=0` (roving tabindex) |
66
- | `renderCell` | `(day, date, state) => ReactNode` | — | Custom cell content renderer |
69
+ | `hoveredDate` | `Date \| null` | `null` | Marks the hovered cell with the `is-hovered` class |
70
+ | `cellData` | `(date: Date) => unknown` | — | Resolve per-cell data; passed to `renderCell` and `onDateClick` |
71
+ | `renderCell` | `(day, date, state, data?) => ReactNode` | — | Custom cell content renderer |
67
72
 
68
73
  The component exports as both named `Calendar` and default.
69
74
 
@@ -81,6 +86,8 @@ Set `interactive` to make day cells clickable. Each cell becomes a `<button clas
81
86
  />
82
87
  ```
83
88
 
89
+ `onDateClick` / `onDateHover` notify the caller but don't touch internal state. To select on click, either use `useCalendarState`'s `selectDateAt(date)` (see below) or the ready-made [`InteractiveCalendar`](#interactivecalendar), which wires click-to-select, hover tracking, and range preview out of the box.
90
+
84
91
  ### `useCalendarState` hook
85
92
 
86
93
  For full interactivity (cursor movement, month navigation, selection), use the `useCalendarState` hook. It wraps the `@typescript-calendar-lib/tui` state machine as React state:
@@ -100,9 +107,13 @@ function App() {
100
107
  goToDate, // (date) => void — jump to a date's month, cursor on that date
101
108
  moveCursor, // (direction) => void — "up" | "down" | "left" | "right"
102
109
  selectDate, // () => void — select date under cursor
110
+ setCursorToDate, // (date) => void — move cursor to a date (same month only)
111
+ selectDateAt, // (date) => void — move cursor to a date and select it
103
112
  clearSelection,
104
113
  cursorDate, // Date | null
105
114
  selectedDate, // Date | null
115
+ hoveredDate, // Date | null
116
+ setHoveredDate, // (date | null) => void
106
117
  } = useCalendarState({
107
118
  initialYear: 2026,
108
119
  initialMonth: 9,
@@ -111,7 +122,13 @@ function App() {
111
122
  return (
112
123
  <>
113
124
  <button onClick={goPrev}>‹</button>
114
- <Calendar year={state.year} month={state.month} interactive />
125
+ <Calendar
126
+ year={state.year}
127
+ month={state.month}
128
+ interactive
129
+ onDateClick={selectDateAt} // click a cell → select it
130
+ onDateHover={setHoveredDate} // track the hovered cell
131
+ />
115
132
  <button onClick={goNext}>›</button>
116
133
  </>
117
134
  );
@@ -122,13 +139,17 @@ function App() {
122
139
 
123
140
  ## InteractiveCalendar
124
141
 
125
- `InteractiveCalendar` bundles `useCalendarState` + `<Calendar>` into a single self-contained component. It manages its own state and supports keyboard navigation out of the box:
142
+ `InteractiveCalendar` bundles `useCalendarState` + `<Calendar>` into a single self-contained component. It manages its own state and supports mouse and keyboard interaction out of the box:
126
143
 
127
- | Key | Action |
144
+ | Input | Action |
128
145
  | :--- | :--- |
146
+ | Click a cell | Selects the date (cursor moves there); fires `onDateClick` |
147
+ | Hover a cell | Tracks the hovered date (adds `is-hovered` class); fires `onDateHover` |
148
+ | Mouse leaves | Clears the hover state; fires `onDateLeave` |
149
+ | Selection + hover | Shows a range preview between the selected date and the hovered date (`is-in-range-preview` class) |
129
150
  | Arrow keys | Move the cursor (focus follows the cursor cell) |
130
151
  | `PageUp` / `PageDown` | Previous / next month |
131
- | Enter / Space | Same as clicking the focused cell |
152
+ | Enter / Space | Same as clicking the focused cell (selects it) |
132
153
 
133
154
  ```tsx
134
155
  import { InteractiveCalendar } from "@typescript-calendar-lib/react";
@@ -142,17 +163,18 @@ function App() {
142
163
  theme="modern"
143
164
  colorScheme="ocean"
144
165
  onMonthChange={(year, month) => console.log("Month:", year, month)}
145
- onDateClick={(date) => console.log("Selected", date)}
166
+ onDateClick={(date, data) => console.log("Selected", date, data)}
167
+ onDateLeave={() => console.log("Mouse left the calendar")}
146
168
  />
147
169
  );
148
170
  }
149
171
  ```
150
172
 
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`).
173
+ It accepts the `useCalendarState` options (`initialYear`, `initialMonth`, `locale`, `weekStart`, `highlight`, `range`, `today`, `onMonthChange`) plus the `Calendar` visual props (`theme`, `colorScheme`, `size`, `responsive`, `style`, `cellData`, `renderCell`) and event callbacks (`onDateClick`, `onDateHover`, `onDateLeave`).
152
174
 
153
175
  ## Custom Cell Rendering
154
176
 
155
- Pass `renderCell` to replace the default day-number content of each cell. It receives the day, the full `Date`, and the cell state:
177
+ Pass `renderCell` to replace the default day-number content of each cell. It receives the day, the full `Date`, the cell state, and (with `cellData`) the resolved data for that date:
156
178
 
157
179
  ```tsx
158
180
  import type { CalendarCellState } from "@typescript-calendar-lib/core";
@@ -160,9 +182,11 @@ import type { CalendarCellState } from "@typescript-calendar-lib/core";
160
182
  <Calendar
161
183
  year={2026}
162
184
  month={9}
163
- renderCell={(day, date, state) => (
185
+ cellData={(date) => (date.getDate() === 15 ? "holiday" : undefined)}
186
+ renderCell={(day, date, state, data) => (
164
187
  <span>
165
188
  {day}
189
+ {data && `(${data})`}
166
190
  {state.isToday && "★"}
167
191
  {state.isInRange && "•"}
168
192
  </span>
@@ -170,6 +194,20 @@ import type { CalendarCellState } from "@typescript-calendar-lib/core";
170
194
  />
171
195
  ```
172
196
 
197
+ `cellData` is called once per real day cell (never for empty cells) and receives the cell's full `Date`; returning `undefined` means "no data". Use it to attach anything — strings, objects, IDs — and consume it in `renderCell` (4th argument) or `onDateClick` (2nd argument):
198
+
199
+ ```tsx
200
+ <Calendar
201
+ year={2026}
202
+ month={9}
203
+ interactive
204
+ cellData={(date) => (date.getDate() === 15 ? "meeting" : undefined)}
205
+ onDateClick={(date, data) => console.log(date, data)} // data: "meeting" | undefined
206
+ />
207
+ ```
208
+
209
+ `cellData`/`renderCell` are render-layer options — they are **not** part of `useCalendarState` (`Calendar` re-renders from its props, so hook-level cell data would have no visible effect).
210
+
173
211
  ---
174
212
 
175
213
  See the interactive demo in the repository docs (`docs/guide/interactive-demo.md`) for a complete example.
@@ -239,6 +277,7 @@ Available variables:
239
277
  | `--cal-highlight-bg` | Highlight background |
240
278
  | `--cal-highlight-fg` | Highlight foreground |
241
279
  | `--cal-range-bg` | Range background |
280
+ | `--cal-range-preview-bg` | Range preview background (falls back to `--cal-range-bg`) |
242
281
  | `--cal-today-bg` | Today background |
243
282
  | `--cal-today-fg` | Today foreground |
244
283
 
@@ -288,6 +327,16 @@ Or custom pixel sizes:
288
327
 
289
328
  Numbers are treated as pixels; strings pass through as CSS lengths (`"3rem"`, `"2.5em"`, etc.).
290
329
 
330
+ ## Responsive
331
+
332
+ The 7-column grid has fixed cell sizes, so on narrow phone screens it can overflow. Pass `responsive` to make the calendar shrink its cells, fonts, and padding below `480px` (and a step tighter below `360px`) and fill the viewport width:
333
+
334
+ ```tsx
335
+ <Calendar year={2026} month={9} responsive />
336
+ ```
337
+
338
+ It's **off by default** to keep existing layouts unchanged. The calendar root gets a `calendar-responsive` class that drives CSS media queries — you can also add that class yourself, or use the `style` prop / your own CSS to tune the breakpoints further.
339
+
291
340
  ## Styling with `style`
292
341
 
293
342
  The `style` prop can override any CSS variable or add custom styles:
@@ -310,6 +359,8 @@ Each day cell gets semantic classes you can target with CSS. In interactive mode
310
359
  | `is-today` | Matches `today` |
311
360
  | `is-highlight` | Matches `highlight` |
312
361
  | `is-in-range` | Inside `range` |
362
+ | `is-in-range-preview` | Inside `rangePreview` |
363
+ | `is-hovered` | Matches `hoveredDate` (interactive mode) |
313
364
 
314
365
  ## Exports
315
366
 
package/dist/calendar.css CHANGED
@@ -10,6 +10,9 @@
10
10
  --cal-range-bg: #fef3c7;
11
11
  --cal-today-bg: #fff7ed;
12
12
  --cal-today-fg: #c2410c;
13
+ --cal-selected-bg: #dc2626;
14
+ --cal-selected-fg: #fff;
15
+ --cal-disabled-fg: #cbd5e1;
13
16
  --cal-cell-w: 2.25rem;
14
17
  --cal-cell-h: 2rem;
15
18
  --cal-font-size: .875rem;
@@ -57,6 +60,12 @@
57
60
  color: var(--cal-weekend-fg);
58
61
  }
59
62
 
63
+ .calendar td.is-disabled {
64
+ color: var(--cal-disabled-fg, var(--cal-weekend-fg));
65
+ opacity: .5;
66
+ text-decoration: line-through;
67
+ }
68
+
60
69
  .calendar td.is-today {
61
70
  background: var(--cal-today-bg);
62
71
  color: var(--cal-today-fg);
@@ -74,6 +83,21 @@
74
83
  background: var(--cal-range-bg);
75
84
  }
76
85
 
86
+ .calendar td.is-in-range-preview {
87
+ background: var(--cal-range-preview-bg, var(--cal-range-bg));
88
+ }
89
+
90
+ .calendar td.is-selected {
91
+ background: var(--cal-selected-bg);
92
+ color: var(--cal-selected-fg);
93
+ font-weight: 700;
94
+ }
95
+
96
+ .calendar td.is-cursor {
97
+ outline: 2px solid var(--cal-accent);
98
+ outline-offset: -2px;
99
+ }
100
+
77
101
  .calendar-size-sm {
78
102
  --cal-cell-w: 1.75rem;
79
103
  --cal-cell-h: 1.5rem;
@@ -182,7 +206,7 @@
182
206
  border-radius: 999px;
183
207
  }
184
208
 
185
- .calendar-theme-rounded td.is-today, .calendar-theme-rounded td.is-highlight, .calendar-theme-rounded td.is-in-range {
209
+ .calendar-theme-rounded td.is-today, .calendar-theme-rounded td.is-highlight, .calendar-theme-rounded td.is-in-range, .calendar-theme-rounded td.is-selected {
186
210
  border-radius: 999px;
187
211
  }
188
212
 
@@ -219,6 +243,22 @@
219
243
  background: var(--cal-range-bg);
220
244
  }
221
245
 
246
+ .calendar-interactive td.is-hovered button.calendar-day-btn {
247
+ background: var(--cal-hover-bg, var(--cal-range-bg));
248
+ }
249
+
250
+ .calendar-interactive td.is-selected button.calendar-day-btn:hover {
251
+ background: var(--cal-selected-bg);
252
+ }
253
+
254
+ .calendar-interactive td.is-disabled button.calendar-day-btn {
255
+ cursor: not-allowed;
256
+ }
257
+
258
+ .calendar-interactive td.is-disabled button.calendar-day-btn:hover {
259
+ background: none;
260
+ }
261
+
222
262
  .calendar-interactive td button.calendar-day-btn:focus-visible {
223
263
  outline: 2px solid var(--cal-accent);
224
264
  outline-offset: -4px;
@@ -228,6 +268,10 @@
228
268
  transform: scale(.95);
229
269
  }
230
270
 
271
+ .calendar-interactive td.is-disabled button.calendar-day-btn:active {
272
+ transform: none;
273
+ }
274
+
231
275
  .calendar-theme-retro {
232
276
  border: 2px solid var(--cal-fg);
233
277
  border-radius: 0;
@@ -261,3 +305,33 @@
261
305
  .calendar-theme-retro td.is-highlight, .calendar-theme-retro td.is-today {
262
306
  border-radius: 0;
263
307
  }
308
+
309
+ @media (width <= 480px) {
310
+ .calendar-responsive {
311
+ box-sizing: border-box;
312
+ --cal-cell-w: 1.75rem;
313
+ --cal-cell-h: 1.5rem;
314
+ --cal-font-size: .75rem;
315
+ --cal-header-font-size: 1rem;
316
+ width: 100%;
317
+ display: block;
318
+ }
319
+
320
+ .calendar-responsive table {
321
+ width: 100%;
322
+ }
323
+
324
+ .calendar-responsive th, .calendar-responsive td {
325
+ box-sizing: border-box;
326
+ padding: .125rem;
327
+ }
328
+ }
329
+
330
+ @media (width <= 360px) {
331
+ .calendar-responsive {
332
+ --cal-cell-w: 1.5rem;
333
+ --cal-cell-h: 1.375rem;
334
+ --cal-font-size: .6875rem;
335
+ --cal-header-font-size: .875rem;
336
+ }
337
+ }
package/dist/index.d.ts CHANGED
@@ -1,33 +1,12 @@
1
1
  import { CalendarCellState, CalendarOptions } from "@typescript-calendar-lib/core";
2
+ import { COLOR_SCHEMES, CalendarCustomSize, CalendarSize, CalendarSizeName, ColorSchemeName, THEMES, ThemeName, WebColorScheme, WebTheme, resolveColorScheme, resolveTheme } from "@typescript-calendar-lib/web";
2
3
  import { CalendarState, CalendarStateOptions, Direction, MonthDirection } from "@typescript-calendar-lib/tui";
3
4
  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
5
  //#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";
6
+ /** React の見た目定義(web の WebTheme と同一構造) */
7
+ type ReactTheme = WebTheme;
27
8
  /** 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;
9
+ type ReactColorScheme = WebColorScheme;
31
10
  //#endregion
32
11
  //#region src/Calendar.d.ts
33
12
  interface CalendarProps {
@@ -43,36 +22,51 @@ interface CalendarProps {
43
22
  };
44
23
  /** 今日の基準日。カラースキームの today 着色に使用 */
45
24
  today?: Date;
25
+ /** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスで視覚化される */
26
+ rangePreview?: {
27
+ from: Date;
28
+ to: Date;
29
+ };
46
30
  /** 見た目テーマ。既定は "default" */
47
31
  theme?: ThemeName | ReactTheme;
48
32
  /** カラースキーム。既定は "default" */
49
33
  colorScheme?: ColorSchemeName | ReactColorScheme;
50
34
  /** セルサイズ。既定は "md"。{ width, height } で自由に指定できる */
51
35
  size?: CalendarSize;
36
+ /** 狭い画面(スマホ等)でセルサイズと余白を自動調整する。既定は false(無効) */
37
+ responsive?: boolean;
52
38
  /** root 要素に追加するスタイル。CSS変数(--cal-*)で自由に上書きできる */
53
39
  style?: CSSProperties;
54
40
  /** インタラクティブモードを有効にする。セルクリック・ホバー・キーボード選択が可能になる */
55
41
  interactive?: boolean;
56
- /** セルクリック時のコールバック */
57
- onDateClick?: (date: Date) => void;
42
+ /** セルクリック時のコールバック。第2引数に該当日のデータ(cellData の戻り値)が渡る */
43
+ onDateClick?: (date: Date, data?: unknown) => void;
58
44
  /** セルホバー時のコールバック */
59
45
  onDateHover?: (date: Date) => void;
46
+ /** カレンダーからマウスが離れたときのコールバック */
47
+ onDateLeave?: () => void;
60
48
  /** キーボード操作。root 要素で発火(矢印キー等を InteractiveCalendar が処理する) */
61
49
  onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;
62
50
  /** 選択済み日付。aria-selected と表示スタイルに使用 */
63
51
  selectedDate?: Date | null;
64
52
  /** カーソル位置の日付。このセルだけ tabIndex=0(roving tabindex)になる */
65
53
  cursorDate?: Date | null;
66
- /** セル内容のカスタムレンダリング。interactive 時は button の子として描画される */
67
- renderCell?: (day: number, date: Date, state: CalendarCellState) => ReactNode;
54
+ /** ホバー中の日付。is-hovered クラスで視覚化される */
55
+ hoveredDate?: Date | null;
56
+ /** セル内容のカスタムレンダリング。interactive 時は button の子として描画される。第4引数に該当日のデータが渡る */
57
+ renderCell?: (day: number, date: Date, state: CalendarCellState, data?: unknown) => ReactNode;
58
+ /** 各セルに付与するユーザー定義データを解決する関数。実セルのみに呼ばれる */
59
+ cellData?: (date: Date) => unknown;
60
+ /** 選択不可日付の判定。true を返した日付は is-disabled クラスになり、インタラクティブ時は選択・ホバーできなくなる */
61
+ isDateDisabled?: (date: Date) => boolean;
68
62
  /** root 要素への ref(React 19 の ref-as-prop) */
69
63
  ref?: Ref<HTMLDivElement>;
70
64
  }
71
65
  /** 月カレンダーコンポーネント */
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;
66
+ export declare function Calendar({ year, month, locale, weekStart, highlight, range, today, theme, colorScheme, size, responsive, style, interactive, onDateClick, onDateHover, onDateLeave, onKeyDown, selectedDate, cursorDate, hoveredDate, renderCell, cellData, isDateDisabled, rangePreview, ref }: CalendarProps): import("react").JSX.Element;
73
67
  //#endregion
74
68
  //#region src/hooks.d.ts
75
- interface UseCalendarStateOptions extends Pick<CalendarStateOptions, "locale" | "weekStart" | "today" | "highlight" | "range"> {
69
+ interface UseCalendarStateOptions extends Pick<CalendarStateOptions, "locale" | "weekStart" | "today" | "highlight" | "range" | "isDateDisabled"> {
76
70
  initialYear?: number;
77
71
  initialMonth?: number;
78
72
  /** 表示中の年月が変わったときに呼ばれる */
@@ -96,12 +90,20 @@ interface UseCalendarStateReturn {
96
90
  goToday: () => void;
97
91
  /** カーソル位置の日付を選択 */
98
92
  selectDate: () => void;
93
+ /** 指定した日付へカーソルを移動する(当月に無ければ何もしない) */
94
+ setCursorToDate: (date: Date) => void;
95
+ /** 指定した日付を選択し、カーソルもそこへ移動する(当月に無ければ何もしない) */
96
+ selectDateAt: (date: Date) => void;
99
97
  /** 選択を解除 */
100
98
  clearSelection: () => void;
101
99
  /** カーソル位置の日付(null の場合あり) */
102
100
  cursorDate: Date | null;
103
101
  /** 選択済み日付(null の場合あり) */
104
102
  selectedDate: Date | null;
103
+ /** ホバー中の日付(null の場合あり) */
104
+ hoveredDate: Date | null;
105
+ /** ホバー日付を更新する */
106
+ setHoveredDate: (date: Date | null) => void;
105
107
  }
106
108
  /**
107
109
  * tui の不変状態マシンを包む React hook。
@@ -127,32 +129,44 @@ interface InteractiveCalendarProps {
127
129
  weekStart?: CalendarOptions["weekStart"];
128
130
  /** ハイライト対象日 */
129
131
  highlight?: Date;
130
- /** 色付け範囲 */
132
+ /** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスで視覚化される */
131
133
  range?: {
132
134
  from: Date;
133
135
  to: Date;
134
136
  };
135
137
  /** 今日の基準日。省略時は初回レンダリング時刻に解決される */
136
138
  today?: Date;
139
+ /** 選択不可日付の判定。true を返した日付は選択・カーソル移動・ホバーの対象外になる */
140
+ isDateDisabled?: (date: Date) => boolean;
137
141
  /** 表示中の年月が変わったときに呼ばれる */
138
142
  onMonthChange?: (year: number, month: number) => void;
139
143
  theme?: ThemeName | ReactTheme;
140
144
  colorScheme?: ColorSchemeName | ReactColorScheme;
141
145
  size?: CalendarSize;
146
+ /** 狭い画面(スマホ等)でセルサイズと余白を自動調整する */
147
+ responsive?: boolean;
142
148
  style?: CSSProperties;
143
- /** セル内容のカスタムレンダリング */
149
+ /** セル内容のカスタムレンダリング。第4引数に該当日のデータが渡る */
144
150
  renderCell?: CalendarProps["renderCell"];
145
- /** セルクリック時(キーボードの Enter/Space 含む) */
146
- onDateClick?: (date: Date) => void;
151
+ /** 各セルに付与するユーザー定義データを解決する関数。実セルのみに呼ばれる */
152
+ cellData?: (date: Date) => unknown;
153
+ /** セルクリック時(キーボードの Enter/Space 含む)。クリックした日付は自動的に選択される。第2引数に該当日のデータが渡る */
154
+ onDateClick?: (date: Date, data?: unknown) => void;
147
155
  /** セルホバー時 */
148
156
  onDateHover?: (date: Date) => void;
157
+ /** カレンダーからマウスが離れたとき */
158
+ onDateLeave?: () => void;
149
159
  }
150
160
  /**
151
161
  * `useCalendarState` と `Calendar` を一体化したインタラクティブカレンダー。
152
- * 内部で状態を管理し、矢印キー(カーソル移動)・PageUp/PageDown(月移動)の
153
- * キーボード操作に対応する。
162
+ * 内部で状態を管理し、以下の操作に対応する:
163
+ *
164
+ * - マウス: セルクリックで日付を選択(カーソルもそこへ移動) / ホバー追跡 /
165
+ * 選択済み日付とホバー日付の間を範囲プレビュー表示
166
+ * - キーボード: 矢印キー(カーソル移動)・PageUp/PageDown(月移動)・
167
+ * Enter/Space(クリックと同じ日付選択)
154
168
  */
155
169
  export declare function InteractiveCalendar(props: InteractiveCalendarProps): import("react").JSX.Element;
156
170
  //#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 };
171
+ export { COLOR_SCHEMES, Calendar as default, type CalendarCustomSize, type CalendarProps, type CalendarSize, type CalendarSizeName, type ColorSchemeName, type InteractiveCalendarProps, type ReactColorScheme, type ReactTheme, THEMES, type ThemeName, type UseCalendarStateOptions, type UseCalendarStateReturn, resolveColorScheme, resolveTheme };
158
172
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,191 +1,67 @@
1
- import { buildMonthGrid, createDate, getCalendarCellState, getMonthName, getWeekdayHeaders, isSameDay } from "@typescript-calendar-lib/core";
1
+ import { buildMonthGrid, createDate, getCalendarCellState, getMonthName, getWeekdayHeaders, isDateInRange, isSameDay, sortRange as buildRangePreview } from "@typescript-calendar-lib/core";
2
+ import { COLOR_SCHEMES, THEMES, buildSizeStyle, formatCellLabel, isSizeName, resolveColorScheme, resolveTheme } from "@typescript-calendar-lib/web";
2
3
  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 { clearSelection, createCalendarState, getCursorDate, getSelectedDate, goToDate, goToMonth, goToToday, keyToAction, moveCursor, navigateMonth, navigateYear, sameStateOptions, selectDate, selectDateAt, setCursorToDate, updateStateOptions } from "@typescript-calendar-lib/tui";
4
5
  import { useCallback, useEffect, useRef, useState } from "react";
5
6
  //#region src/cell-classes.ts
6
- /** セル状態に応じた CSS クラスを組み立てる */
7
- function stateToClasses(state) {
7
+ /** 日付セルの状態(週末・今日・ハイライト・範囲・選択・カーソル)に応じた CSS クラスを組み立てる */
8
+ function getCellClasses(date, options) {
9
+ const state = getCalendarCellState(date, options);
8
10
  const classes = [];
9
11
  if (state.isWeekend) classes.push("is-weekend");
10
12
  if (state.isToday) classes.push("is-today");
11
13
  if (state.isHighlight) classes.push("is-highlight");
12
14
  if (state.isInRange) classes.push("is-in-range");
15
+ if (options.rangePreview !== void 0 && isDateInRange(date, options.rangePreview)) classes.push("is-in-range-preview");
16
+ if (state.isDisabled) classes.push("is-disabled");
17
+ if (options.hoveredDate != null && isSameDay(date, options.hoveredDate)) classes.push("is-hovered");
18
+ if (options.selected != null && isSameDay(date, options.selected)) classes.push("is-selected");
19
+ if (options.cursorDate != null && isSameDay(date, options.cursorDate)) classes.push("is-cursor");
13
20
  return classes.join(" ");
14
21
  }
15
22
  //#endregion
16
23
  //#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;
24
+ /** セルサイズを CSS 変数スタイル(--cal-cell-w / --cal-cell-h)へ変換する */
25
+ function buildSizeStyle$1(size) {
26
+ return buildSizeStyle(size);
160
27
  }
161
28
  //#endregion
162
29
  //#region src/Calendar.tsx
163
30
  /** 月カレンダーコンポーネント */
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 }) {
31
+ function Calendar({ year, month, locale = "en", weekStart = "sunday", highlight, range, today, theme = "default", colorScheme = "default", size = "md", responsive = false, style, interactive = false, onDateClick, onDateHover, onDateLeave, onKeyDown, selectedDate = null, cursorDate = null, hoveredDate = null, renderCell, cellData, isDateDisabled, rangePreview, ref }) {
165
32
  const cellDate = (day) => createDate(year, month - 1, day);
166
- const cellState = (day) => getCalendarCellState(cellDate(day), {
33
+ const className = (day) => getCellClasses(cellDate(day), {
167
34
  today,
168
35
  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);
36
+ range,
37
+ rangePreview,
38
+ hoveredDate,
39
+ selected: selectedDate,
40
+ cursorDate,
41
+ isDateDisabled
42
+ }) || void 0;
174
43
  const handleCellClick = (day) => {
175
- if (interactive && onDateClick) onDateClick(cellDate(day));
44
+ if (interactive && onDateClick) {
45
+ const date = cellDate(day);
46
+ onDateClick(date, cellData?.(date));
47
+ }
176
48
  };
177
49
  const handleCellHover = (day) => {
178
50
  if (interactive && onDateHover) onDateHover(cellDate(day));
179
51
  };
52
+ const handleMouseLeave = () => {
53
+ if (interactive && onDateLeave) onDateLeave();
54
+ };
180
55
  const title = `${getMonthName(locale, month)} ${year}`;
181
56
  const gridRole = interactive ? "grid" : void 0;
182
57
  const cellRole = interactive ? "gridcell" : void 0;
183
58
  return /* @__PURE__ */ jsxs("div", {
184
59
  ref,
185
- className: `calendar ${resolveTheme(theme).className}${isSizeName(size) ? ` calendar-size-${size}` : ""}${interactive ? " calendar-interactive" : ""}`,
60
+ className: `calendar ${resolveTheme(theme).className}${isSizeName(size) ? ` calendar-size-${size}` : ""}${interactive ? " calendar-interactive" : ""}${responsive ? " calendar-responsive" : ""}`,
61
+ onMouseLeave: interactive ? handleMouseLeave : void 0,
186
62
  style: {
187
63
  ...resolveColorScheme(colorScheme),
188
- ...buildSizeStyle(size),
64
+ ...buildSizeStyle$1(size),
189
65
  ...style
190
66
  },
191
67
  children: [/* @__PURE__ */ jsx("div", {
@@ -199,26 +75,35 @@ function Calendar({ year, month, locale = "en", weekStart = "sunday", highlight,
199
75
  if (row.every((d) => d === null)) return null;
200
76
  return /* @__PURE__ */ jsx("tr", { children: row.map((day, j) => {
201
77
  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);
78
+ const date = cellDate(day);
79
+ const state = getCalendarCellState(date, {
80
+ today,
81
+ highlight,
82
+ range,
83
+ isDateDisabled
84
+ });
85
+ const data = cellData?.(date);
86
+ const selected = selectedDate !== null && isSameDay(date, selectedDate);
87
+ const cursor = cursorDate !== null && isSameDay(date, cursorDate);
205
88
  return /* @__PURE__ */ jsx("td", {
206
89
  role: cellRole,
207
90
  tabIndex: interactive ? -1 : void 0,
208
- className: cellClass(day),
91
+ className: className(day),
209
92
  "aria-selected": selected || void 0,
210
93
  "aria-current": state.isToday ? "date" : void 0,
94
+ "aria-disabled": state.isDisabled || void 0,
211
95
  children: interactive ? /* @__PURE__ */ jsx("button", {
212
96
  type: "button",
213
97
  className: "calendar-day-btn",
214
- onClick: () => handleCellClick(day),
215
- onMouseEnter: () => handleCellHover(day),
98
+ onClick: state.isDisabled ? void 0 : () => handleCellClick(day),
99
+ onMouseEnter: state.isDisabled ? void 0 : () => handleCellHover(day),
216
100
  tabIndex: cursor ? 0 : -1,
217
101
  "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);
102
+ "aria-label": formatCellLabel(locale, year, month, day),
103
+ disabled: state.isDisabled,
104
+ children: renderCell ? renderCell(day, date, state, data) : day
105
+ }) : renderCell ? renderCell(day, date, state, data) : day
106
+ }, `d-${day}`);
222
107
  }) }, i);
223
108
  }) })]
224
109
  })]
@@ -239,15 +124,8 @@ function Calendar({ year, month, locale = "en", weekStart = "sunday", highlight,
239
124
  * 引き継がれる(毎レンダリング `new Date()` を渡さなくてよい)。
240
125
  */
241
126
  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
- }));
127
+ const [state, setState] = useState(() => createCalendarState(options));
128
+ const [hoveredDate, setHoveredDate] = useState(null);
251
129
  const prevOptions = useRef(options);
252
130
  useEffect(() => {
253
131
  if (sameStateOptions(prevOptions.current, options)) return;
@@ -269,6 +147,7 @@ function useCalendarState(options = {}) {
269
147
  month: state.month
270
148
  };
271
149
  onMonthChangeRef.current?.(state.year, state.month);
150
+ setHoveredDate(null);
272
151
  }
273
152
  }, [state.year, state.month]);
274
153
  return {
@@ -281,20 +160,28 @@ function useCalendarState(options = {}) {
281
160
  goToDate: useCallback((date) => setState((prev) => goToDate(prev, date)), []),
282
161
  goToday: useCallback(() => setState((prev) => goToToday(prev)), []),
283
162
  selectDate: useCallback(() => setState((prev) => selectDate(prev)), []),
163
+ setCursorToDate: useCallback((date) => setState((prev) => setCursorToDate(prev, date)), []),
164
+ selectDateAt: useCallback((date) => setState((prev) => selectDateAt(prev, date)), []),
284
165
  clearSelection: useCallback(() => setState((prev) => clearSelection(prev)), []),
285
166
  cursorDate: getCursorDate(state),
286
- selectedDate: getSelectedDate(state)
167
+ selectedDate: getSelectedDate(state),
168
+ hoveredDate,
169
+ setHoveredDate
287
170
  };
288
171
  }
289
172
  //#endregion
290
173
  //#region src/interactive.tsx
291
174
  /**
292
175
  * `useCalendarState` と `Calendar` を一体化したインタラクティブカレンダー。
293
- * 内部で状態を管理し、矢印キー(カーソル移動)・PageUp/PageDown(月移動)の
294
- * キーボード操作に対応する。
176
+ * 内部で状態を管理し、以下の操作に対応する:
177
+ *
178
+ * - マウス: セルクリックで日付を選択(カーソルもそこへ移動) / ホバー追跡 /
179
+ * 選択済み日付とホバー日付の間を範囲プレビュー表示
180
+ * - キーボード: 矢印キー(カーソル移動)・PageUp/PageDown(月移動)・
181
+ * Enter/Space(クリックと同じ日付選択)
295
182
  */
296
183
  function InteractiveCalendar(props) {
297
- const { initialYear, initialMonth, locale, weekStart, highlight, range, today, onMonthChange, theme, colorScheme, size, style, renderCell, onDateClick, onDateHover } = props;
184
+ const { initialYear, initialMonth, locale, weekStart, highlight, range, today, isDateDisabled, onMonthChange, theme, colorScheme, size, responsive, style, renderCell, cellData, onDateClick, onDateHover, onDateLeave } = props;
298
185
  const hook = useCalendarState({
299
186
  initialYear,
300
187
  initialMonth,
@@ -303,10 +190,24 @@ function InteractiveCalendar(props) {
303
190
  today,
304
191
  highlight,
305
192
  range,
193
+ isDateDisabled,
306
194
  onMonthChange
307
195
  });
308
- const { state, moveCursor, goPrev, goNext } = hook;
196
+ const { state, moveCursor, goPrev, goNext, selectDateAt, setHoveredDate } = hook;
309
197
  const rootRef = useRef(null);
198
+ const handleDateClick = useCallback((date, data) => {
199
+ selectDateAt(date);
200
+ onDateClick?.(date, data);
201
+ }, [selectDateAt, onDateClick]);
202
+ const handleDateHover = useCallback((date) => {
203
+ setHoveredDate(date);
204
+ onDateHover?.(date);
205
+ }, [setHoveredDate, onDateHover]);
206
+ const handleDateLeave = useCallback(() => {
207
+ setHoveredDate(null);
208
+ onDateLeave?.();
209
+ }, [setHoveredDate, onDateLeave]);
210
+ const rangePreview = buildRangePreview(hook.selectedDate, hook.hoveredDate);
310
211
  const prevCursorRef = useRef(state.cursor);
311
212
  useEffect(() => {
312
213
  const prev = prevCursorRef.current;
@@ -315,30 +216,17 @@ function InteractiveCalendar(props) {
315
216
  (rootRef.current?.querySelector("[data-cursor=\"true\"]"))?.focus();
316
217
  }, [state.cursor]);
317
218
  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();
219
+ const action = keyToAction(e.key);
220
+ if (action === void 0) return;
221
+ e.preventDefault();
222
+ switch (action) {
223
+ case "prev":
337
224
  goPrev();
338
225
  break;
339
- case "PageDown":
340
- e.preventDefault();
226
+ case "next":
341
227
  goNext();
228
+ break;
229
+ default: moveCursor(action);
342
230
  }
343
231
  }, [
344
232
  moveCursor,
@@ -354,16 +242,22 @@ function InteractiveCalendar(props) {
354
242
  highlight: state.options.highlight,
355
243
  range: state.options.range,
356
244
  today: state.options.today,
245
+ isDateDisabled,
357
246
  theme,
358
247
  colorScheme,
359
248
  size,
249
+ responsive,
360
250
  style,
361
251
  interactive: true,
362
252
  renderCell,
253
+ cellData,
363
254
  selectedDate: hook.selectedDate,
364
255
  cursorDate: hook.cursorDate,
365
- onDateClick,
366
- onDateHover,
256
+ hoveredDate: hook.hoveredDate,
257
+ rangePreview,
258
+ onDateClick: handleDateClick,
259
+ onDateHover: handleDateHover,
260
+ onDateLeave: handleDateLeave,
367
261
  onKeyDown: handleKeyDown
368
262
  });
369
263
  }
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/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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G,CAAC,MAAM,MAAM,CAAC;CAEjB,MAAM,gBAAgB,aACnB,MAA8D;EAC7D,QAAQ,EAAE,KAAV;GACE,KAAK;IACH,EAAE,eAAe;IACjB,WAAW,OAAO;IAClB;GACF,KAAK;IACH,EAAE,eAAe;IACjB,WAAW,MAAM;IACjB;GACF,KAAK;IACH,EAAE,eAAe;IACjB,WAAW,MAAM;IACjB;GACF,KAAK;IACH,EAAE,eAAe;IACjB,WAAW,IAAI;IACf;GACF,KAAK;IACH,EAAE,eAAe;IACjB,OAAO;IACP;GACF,KAAK;IACH,EAAE,eAAe;IACjB,OAAO;EAEX;CACF,GACA;EAAC;EAAY;EAAQ;CAAM,CAC7B;CAEA,OACE,oBAAC,UAAD;EACE,KAAK;EACL,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,QAAQ,MAAM,QAAQ;EACtB,WAAW,MAAM,QAAQ;EACzB,WAAW,MAAM,QAAQ;EACzB,OAAO,MAAM,QAAQ;EACrB,OAAO,MAAM,QAAQ;EACd;EACM;EACP;EACC;EACP,aAAA;EACY;EACZ,cAAc,KAAK;EACnB,YAAY,KAAK;EACJ;EACA;EACb,WAAW;CACZ,CAAA;AAEL"}
1
+ {"version":3,"file":"index.js","names":["buildSizeStyle","buildSizeStyleBase","buildSizeStyle"],"sources":["../src/cell-classes.ts","../src/size.ts","../src/Calendar.tsx","../src/hooks.ts","../src/interactive.tsx"],"sourcesContent":["import {\n getCalendarCellState,\n isDateInRange,\n isSameDay,\n} from \"@typescript-calendar-lib/core\";\n\n// ─── セル状態クラス ───────────────────────────────────────\n\nexport interface CellStateOptions {\n today?: Date;\n highlight?: Date;\n range?: { from: Date; to: Date };\n /** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスになる */\n rangePreview?: { from: Date; to: Date };\n /** ホバー中の日付。is-hovered クラスになる */\n hoveredDate?: Date | null;\n /** 選択済み日付。該当セルに is-selected クラスが付く */\n selected?: Date | null;\n /** カーソル位置の日付。該当セルに is-cursor クラスが付く */\n cursorDate?: Date | null;\n /** 選択不可日付の判定。該当セルに is-disabled クラスが付く */\n isDateDisabled?: (date: Date) => boolean;\n}\n\n// 範囲の from > to は不正入力として RangeError(isDateInRange が検証する)\n\n/** 日付セルの状態(週末・今日・ハイライト・範囲・選択・カーソル)に応じた CSS クラスを組み立てる */\nexport function getCellClasses(date: Date, options: CellStateOptions): string {\n const state = getCalendarCellState(date, options);\n const classes: string[] = [];\n if (state.isWeekend) classes.push(\"is-weekend\");\n if (state.isToday) classes.push(\"is-today\");\n if (state.isHighlight) classes.push(\"is-highlight\");\n if (state.isInRange) classes.push(\"is-in-range\");\n if (\n options.rangePreview !== undefined &&\n isDateInRange(date, options.rangePreview)\n )\n classes.push(\"is-in-range-preview\");\n if (state.isDisabled) classes.push(\"is-disabled\");\n if (options.hoveredDate != null && isSameDay(date, options.hoveredDate))\n classes.push(\"is-hovered\");\n if (options.selected != null && isSameDay(date, options.selected))\n classes.push(\"is-selected\");\n if (options.cursorDate != null && isSameDay(date, options.cursorDate))\n classes.push(\"is-cursor\");\n return classes.join(\" \");\n}\n","// ─── セルサイズ ───────────────────────────────────────────\n// サイズ判定・CSS 変数変換は web パッケージに集約済み。\n// ここでは React の style 型(CSSProperties)に適合させる薄いアダプタのみ持つ。\n\nimport type { CalendarSize } from \"@typescript-calendar-lib/web\";\nimport type { CSSProperties } from \"react\";\n\nexport type {\n CalendarCustomSize,\n CalendarSize,\n CalendarSizeName,\n} from \"@typescript-calendar-lib/web\";\nexport { isSizeName } from \"@typescript-calendar-lib/web\";\n\nimport { buildSizeStyle as buildSizeStyleBase } from \"@typescript-calendar-lib/web\";\n\n/** セルサイズを CSS 変数スタイル(--cal-cell-w / --cal-cell-h)へ変換する */\nexport function buildSizeStyle(size: CalendarSize): CSSProperties {\n return buildSizeStyleBase(size) as CSSProperties;\n}\n","import type {\n CalendarCellState,\n CalendarOptions,\n} from \"@typescript-calendar-lib/core\";\nimport {\n buildMonthGrid,\n createDate,\n getCalendarCellState,\n getMonthName,\n getWeekdayHeaders,\n isSameDay,\n} from \"@typescript-calendar-lib/core\";\nimport { formatCellLabel } from \"@typescript-calendar-lib/web\";\nimport type {\n CSSProperties,\n KeyboardEvent as ReactKeyboardEvent,\n ReactNode,\n Ref,\n} from \"react\";\nimport { getCellClasses } from \"./cell-classes.ts\";\nimport type { CalendarSize } from \"./size.ts\";\nimport { buildSizeStyle, isSizeName } from \"./size.ts\";\nimport type {\n ColorSchemeName,\n ReactColorScheme,\n ReactTheme,\n ThemeName,\n} from \"./themes.ts\";\nimport { resolveColorScheme, resolveTheme } from \"./themes.ts\";\n\nexport type {\n CalendarCustomSize,\n CalendarSize,\n CalendarSizeName,\n} from \"./size.ts\";\n\nexport interface CalendarProps {\n year: number;\n month: number;\n locale?: CalendarOptions[\"locale\"];\n weekStart?: CalendarOptions[\"weekStart\"];\n highlight?: Date;\n /** 範囲強調 */\n range?: { from: Date; to: Date };\n /** 今日の基準日。カラースキームの today 着色に使用 */\n today?: Date;\n /** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスで視覚化される */\n rangePreview?: { from: Date; to: Date };\n /** 見た目テーマ。既定は \"default\" */\n theme?: ThemeName | ReactTheme;\n /** カラースキーム。既定は \"default\" */\n colorScheme?: ColorSchemeName | ReactColorScheme;\n /** セルサイズ。既定は \"md\"。{ width, height } で自由に指定できる */\n size?: CalendarSize;\n /** 狭い画面(スマホ等)でセルサイズと余白を自動調整する。既定は false(無効) */\n responsive?: boolean;\n /** root 要素に追加するスタイル。CSS変数(--cal-*)で自由に上書きできる */\n style?: CSSProperties;\n\n // ── インタラクション ──\n\n /** インタラクティブモードを有効にする。セルクリック・ホバー・キーボード選択が可能になる */\n interactive?: boolean;\n /** セルクリック時のコールバック。第2引数に該当日のデータ(cellData の戻り値)が渡る */\n onDateClick?: (date: Date, data?: unknown) => void;\n /** セルホバー時のコールバック */\n onDateHover?: (date: Date) => void;\n /** カレンダーからマウスが離れたときのコールバック */\n onDateLeave?: () => void;\n /** キーボード操作。root 要素で発火(矢印キー等を InteractiveCalendar が処理する) */\n onKeyDown?: (event: ReactKeyboardEvent<HTMLDivElement>) => void;\n\n // ── セル状態 ──\n\n /** 選択済み日付。aria-selected と表示スタイルに使用 */\n selectedDate?: Date | null;\n /** カーソル位置の日付。このセルだけ tabIndex=0(roving tabindex)になる */\n cursorDate?: Date | null;\n /** ホバー中の日付。is-hovered クラスで視覚化される */\n hoveredDate?: Date | null;\n /** セル内容のカスタムレンダリング。interactive 時は button の子として描画される。第4引数に該当日のデータが渡る */\n renderCell?: (\n day: number,\n date: Date,\n state: CalendarCellState,\n data?: unknown,\n ) => ReactNode;\n /** 各セルに付与するユーザー定義データを解決する関数。実セルのみに呼ばれる */\n cellData?: (date: Date) => unknown;\n /** 選択不可日付の判定。true を返した日付は is-disabled クラスになり、インタラクティブ時は選択・ホバーできなくなる */\n isDateDisabled?: (date: Date) => boolean;\n\n /** root 要素への ref(React 19 の ref-as-prop) */\n ref?: Ref<HTMLDivElement>;\n}\n\n/** 月カレンダーコンポーネント */\nexport function Calendar({\n year,\n month,\n locale = \"en\",\n weekStart = \"sunday\",\n highlight,\n range,\n today,\n theme = \"default\",\n colorScheme = \"default\",\n size = \"md\",\n responsive = false,\n style,\n interactive = false,\n onDateClick,\n onDateHover,\n onDateLeave,\n onKeyDown,\n selectedDate = null,\n cursorDate = null,\n hoveredDate = null,\n renderCell,\n cellData,\n isDateDisabled,\n rangePreview,\n ref,\n}: CalendarProps) {\n const cellDate = (day: number): Date => createDate(year, month - 1, day);\n const className = (day: number): string | undefined =>\n getCellClasses(cellDate(day), {\n today,\n highlight,\n range,\n rangePreview,\n hoveredDate,\n selected: selectedDate,\n cursorDate,\n isDateDisabled,\n }) || undefined;\n\n const handleCellClick = (day: number) => {\n if (interactive && onDateClick) {\n const date = cellDate(day);\n onDateClick(date, cellData?.(date));\n }\n };\n\n const handleCellHover = (day: number) => {\n if (interactive && onDateHover) onDateHover(cellDate(day));\n };\n\n const handleMouseLeave = () => {\n if (interactive && onDateLeave) onDateLeave();\n };\n\n const title = `${getMonthName(locale, month)} ${year}`;\n // インタラクティブ時のみ APG の grid セマンティクスを付与する。\n // 静的表示ではネイティブの table/cell セマンティクスをそのまま使う。\n const gridRole = interactive ? \"grid\" : undefined;\n const cellRole = interactive ? \"gridcell\" : undefined;\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: onMouseLeave はホバー状態クリア用の補助イベント。キーボード操作(role=grid)は独立して対応済み\n <div\n ref={ref}\n className={`calendar ${resolveTheme(theme).className}${isSizeName(size) ? ` calendar-size-${size}` : \"\"}${interactive ? \" calendar-interactive\" : \"\"}${responsive ? \" calendar-responsive\" : \"\"}`}\n onMouseLeave={interactive ? handleMouseLeave : undefined}\n style={{\n ...(resolveColorScheme(colorScheme) as CSSProperties),\n ...buildSizeStyle(size),\n ...style,\n }}\n >\n <div className=\"calendar-header\">\n <h2>{title}</h2>\n </div>\n <table role={gridRole} aria-label={title} onKeyDown={onKeyDown}>\n <thead>\n <tr>\n {getWeekdayHeaders(locale, weekStart).map((day) => (\n <th key={day}>{day}</th>\n ))}\n </tr>\n </thead>\n <tbody>\n {buildMonthGrid(year, month, weekStart).map((row, i) => {\n if (row.every((d) => d === null)) return null;\n return (\n // biome-ignore lint/suspicious/noArrayIndexKey: 月グリッドは静的で並び順が変わらない\n <tr key={i}>\n {row.map((day, j) => {\n if (day === null)\n // biome-ignore lint/suspicious/noArrayIndexKey: パディングセルは位置が唯一の識別子\n return <td key={j} role={cellRole} />;\n const date = cellDate(day);\n const state = getCalendarCellState(date, {\n today,\n highlight,\n range,\n isDateDisabled,\n });\n const data = cellData?.(date);\n const selected =\n selectedDate !== null && isSameDay(date, selectedDate);\n const cursor =\n cursorDate !== null && isSameDay(date, cursorDate);\n return (\n // biome-ignore lint/a11y/useAriaPropsSupportedByRole: interactive 時は td に role=gridcell が付き aria-selected は有効(role が動的なため静的解析できない)\n <td\n // パディングセル(key=j)との衝突を避けるため日番号に \"d-\" を付与する。日番号は列位置 j と異なり配列の index ではない\n key={`d-${day}`}\n role={cellRole}\n tabIndex={interactive ? -1 : undefined}\n className={className(day)}\n aria-selected={selected || undefined}\n aria-current={state.isToday ? \"date\" : undefined}\n aria-disabled={state.isDisabled || undefined}\n >\n {interactive ? (\n <button\n type=\"button\"\n className=\"calendar-day-btn\"\n onClick={\n state.isDisabled\n ? undefined\n : () => handleCellClick(day)\n }\n onMouseEnter={\n state.isDisabled\n ? undefined\n : () => handleCellHover(day)\n }\n tabIndex={cursor ? 0 : -1}\n data-cursor={cursor ? \"true\" : undefined}\n aria-label={formatCellLabel(locale, year, month, day)}\n disabled={state.isDisabled}\n >\n {renderCell\n ? renderCell(day, date, state, data)\n : day}\n </button>\n ) : renderCell ? (\n renderCell(day, date, state, data)\n ) : (\n day\n )}\n </td>\n );\n })}\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n}\n\nexport default Calendar;\n","import type {\n CalendarState,\n CalendarStateOptions,\n Direction,\n MonthDirection,\n} from \"@typescript-calendar-lib/tui\";\nimport {\n clearSelection,\n createCalendarState,\n getCursorDate,\n getSelectedDate,\n goToDate,\n goToMonth,\n goToToday,\n moveCursor,\n navigateMonth,\n navigateYear,\n sameStateOptions,\n selectDate,\n selectDateAt,\n setCursorToDate,\n updateStateOptions,\n} from \"@typescript-calendar-lib/tui\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport interface UseCalendarStateOptions\n extends Pick<\n CalendarStateOptions,\n \"locale\" | \"weekStart\" | \"today\" | \"highlight\" | \"range\" | \"isDateDisabled\"\n > {\n initialYear?: number;\n initialMonth?: number;\n /** 表示中の年月が変わったときに呼ばれる */\n onMonthChange?: (year: number, month: number) => void;\n}\n\nexport interface UseCalendarStateReturn {\n /** 現在のカレンダー状態 */\n state: CalendarState;\n /** カーソルを指定方向に移動 (wrap around) */\n moveCursor: (direction: Direction) => void;\n /** 前月/翌月へ移動 */\n goNext: () => void;\n goPrev: () => void;\n /** 前年/翌年へ移動 */\n navigateYear: (direction: MonthDirection) => void;\n /** 指定した年月へジャンプ */\n goToMonth: (year: number, month: number) => void;\n /** 指定した日付の月へジャンプし、カーソルをその日付に置く */\n goToDate: (date: Date) => void;\n /** 今日の月へジャンプ */\n goToday: () => void;\n /** カーソル位置の日付を選択 */\n selectDate: () => void;\n /** 指定した日付へカーソルを移動する(当月に無ければ何もしない) */\n setCursorToDate: (date: Date) => void;\n /** 指定した日付を選択し、カーソルもそこへ移動する(当月に無ければ何もしない) */\n selectDateAt: (date: Date) => void;\n /** 選択を解除 */\n clearSelection: () => void;\n /** カーソル位置の日付(null の場合あり) */\n cursorDate: Date | null;\n /** 選択済み日付(null の場合あり) */\n selectedDate: Date | null;\n /** ホバー中の日付(null の場合あり) */\n hoveredDate: Date | null;\n /** ホバー日付を更新する */\n setHoveredDate: (date: Date | null) => void;\n}\n\n/**\n * tui の不変状態マシンを包む React hook。\n * カレンダーのインタラクティブ操作をシンプルに利用できる。\n *\n * `options` の値(locale / weekStart / today / highlight / range /\n * initialYear / initialMonth)が変わると、カーソル・選択を保ったまま\n * 状態が再構築される。比較は値(Date は getTime)で行うため、インラインで\n * オプションを渡しても値が同じなら再構築されない。\n *\n * `today` を省略した場合、最初に解決された値が状態に固定され、以降も\n * 引き継がれる(毎レンダリング `new Date()` を渡さなくてよい)。\n */\nexport function useCalendarState(\n options: UseCalendarStateOptions = {},\n): UseCalendarStateReturn {\n const [state, setState] = useState<CalendarState>(() =>\n createCalendarState(options),\n );\n\n // ホバー中の日付は React ローカル state で保持する(tui 状態には入れない)。\n const [hoveredDate, setHoveredDate] = useState<Date | null>(null);\n\n // options の「値の変化」を検知して状態を再構築する。\n // 初回は prevOptions が同一なので何もしない。値が同じままの再レンダリング\n // でも何もしないため、インラインリテラルを毎回渡しても無限ループしない。\n const prevOptions = useRef(options);\n useEffect(() => {\n if (sameStateOptions(prevOptions.current, options)) return;\n const previous = prevOptions.current;\n prevOptions.current = options;\n setState((current) => updateStateOptions(current, options, previous));\n }, [options]);\n\n // onMonthChange: ref 経由で安定参照\n const onMonthChangeRef = useRef(options.onMonthChange);\n onMonthChangeRef.current = options.onMonthChange;\n\n // 表示月が変わったら onMonthChange を通知し、古い月を指すホバーをクリアする\n const prevMonthRef = useRef({ year: state.year, month: state.month });\n useEffect(() => {\n const prev = prevMonthRef.current;\n if (prev.year !== state.year || prev.month !== state.month) {\n prevMonthRef.current = { year: state.year, month: state.month };\n onMonthChangeRef.current?.(state.year, state.month);\n setHoveredDate(null);\n }\n }, [state.year, state.month]);\n\n return {\n state,\n moveCursor: useCallback(\n (direction: Direction) => setState((prev) => moveCursor(prev, direction)),\n [],\n ),\n goNext: useCallback(\n () => setState((prev) => navigateMonth(prev, \"next\")),\n [],\n ),\n goPrev: useCallback(\n () => setState((prev) => navigateMonth(prev, \"prev\")),\n [],\n ),\n navigateYear: useCallback(\n (direction: MonthDirection) =>\n setState((prev) => navigateYear(prev, direction)),\n [],\n ),\n goToMonth: useCallback(\n (year: number, month: number) =>\n setState((prev) => goToMonth(prev, year, month)),\n [],\n ),\n goToDate: useCallback(\n (date: Date) => setState((prev) => goToDate(prev, date)),\n [],\n ),\n goToday: useCallback(() => setState((prev) => goToToday(prev)), []),\n selectDate: useCallback(() => setState((prev) => selectDate(prev)), []),\n setCursorToDate: useCallback(\n (date: Date) => setState((prev) => setCursorToDate(prev, date)),\n [],\n ),\n selectDateAt: useCallback(\n (date: Date) => setState((prev) => selectDateAt(prev, date)),\n [],\n ),\n clearSelection: useCallback(\n () => setState((prev) => clearSelection(prev)),\n [],\n ),\n cursorDate: getCursorDate(state),\n selectedDate: getSelectedDate(state),\n hoveredDate,\n setHoveredDate,\n };\n}\n\nexport type { Direction, MonthDirection };\n","import type { CalendarOptions } from \"@typescript-calendar-lib/core\";\nimport { keyToAction } from \"@typescript-calendar-lib/tui\";\nimport type { CSSProperties } from \"react\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { Calendar, type CalendarProps } from \"./Calendar.tsx\";\nimport { useCalendarState } from \"./hooks.ts\";\nimport { buildRangePreview } from \"./range-preview.ts\";\nimport type { CalendarSize } from \"./size.ts\";\nimport type {\n ColorSchemeName,\n ReactColorScheme,\n ReactTheme,\n ThemeName,\n} from \"./themes.ts\";\n\nexport interface InteractiveCalendarProps {\n // ── useCalendarState オプション ──\n\n /** 表示開始年。既定は today の年 */\n initialYear?: number;\n /** 表示開始月 (1-12)。範囲外は正規化される */\n initialMonth?: number;\n locale?: CalendarOptions[\"locale\"];\n weekStart?: CalendarOptions[\"weekStart\"];\n /** ハイライト対象日 */\n highlight?: Date;\n /** 範囲プレビュー(ホバー等の候補範囲)。is-in-range-preview クラスで視覚化される */\n range?: { from: Date; to: Date };\n /** 今日の基準日。省略時は初回レンダリング時刻に解決される */\n today?: Date;\n /** 選択不可日付の判定。true を返した日付は選択・カーソル移動・ホバーの対象外になる */\n isDateDisabled?: (date: Date) => boolean;\n /** 表示中の年月が変わったときに呼ばれる */\n onMonthChange?: (year: number, month: number) => void;\n\n // ── Calendar の見た目 ──\n\n theme?: ThemeName | ReactTheme;\n colorScheme?: ColorSchemeName | ReactColorScheme;\n size?: CalendarSize;\n /** 狭い画面(スマホ等)でセルサイズと余白を自動調整する */\n responsive?: boolean;\n style?: CSSProperties;\n /** セル内容のカスタムレンダリング。第4引数に該当日のデータが渡る */\n renderCell?: CalendarProps[\"renderCell\"];\n /** 各セルに付与するユーザー定義データを解決する関数。実セルのみに呼ばれる */\n cellData?: (date: Date) => unknown;\n\n // ── イベント ──\n\n /** セルクリック時(キーボードの Enter/Space 含む)。クリックした日付は自動的に選択される。第2引数に該当日のデータが渡る */\n onDateClick?: (date: Date, data?: unknown) => void;\n /** セルホバー時 */\n onDateHover?: (date: Date) => void;\n /** カレンダーからマウスが離れたとき */\n onDateLeave?: () => void;\n}\n\n/**\n * `useCalendarState` と `Calendar` を一体化したインタラクティブカレンダー。\n * 内部で状態を管理し、以下の操作に対応する:\n *\n * - マウス: セルクリックで日付を選択(カーソルもそこへ移動) / ホバー追跡 /\n * 選択済み日付とホバー日付の間を範囲プレビュー表示\n * - キーボード: 矢印キー(カーソル移動)・PageUp/PageDown(月移動)・\n * Enter/Space(クリックと同じ日付選択)\n */\nexport function InteractiveCalendar(props: InteractiveCalendarProps) {\n const {\n initialYear,\n initialMonth,\n locale,\n weekStart,\n highlight,\n range,\n today,\n isDateDisabled,\n onMonthChange,\n theme,\n colorScheme,\n size,\n responsive,\n style,\n renderCell,\n cellData,\n onDateClick,\n onDateHover,\n onDateLeave,\n } = props;\n\n const hook = useCalendarState({\n initialYear,\n initialMonth,\n locale,\n weekStart,\n today,\n highlight,\n range,\n isDateDisabled,\n onMonthChange,\n });\n\n const { state, moveCursor, goPrev, goNext, selectDateAt, setHoveredDate } =\n hook;\n const rootRef = useRef<HTMLDivElement>(null);\n\n // クリック(マウス・Enter/Space 共通)で日付を選択する。\n // 従来の onDateClick コールバックも引き続き発火し、第2引数に該当日のデータが渡る。\n const handleDateClick = useCallback(\n (date: Date, data?: unknown) => {\n selectDateAt(date);\n onDateClick?.(date, data);\n },\n [selectDateAt, onDateClick],\n );\n\n const handleDateHover = useCallback(\n (date: Date) => {\n setHoveredDate(date);\n onDateHover?.(date);\n },\n [setHoveredDate, onDateHover],\n );\n\n const handleDateLeave = useCallback(() => {\n setHoveredDate(null);\n onDateLeave?.();\n }, [setHoveredDate, onDateLeave]);\n\n // 選択済み日付とホバー日付の間を範囲プレビューとして表示する\n const rangePreview = buildRangePreview(hook.selectedDate, hook.hoveredDate);\n\n // カーソルが動いたときだけ、そのセルへフォーカスを移す(初回マウントでは動かさない)\n const prevCursorRef = useRef(state.cursor);\n useEffect(() => {\n const prev = prevCursorRef.current;\n prevCursorRef.current = state.cursor;\n if (prev === state.cursor) return;\n const btn = rootRef.current?.querySelector<HTMLButtonElement>(\n '[data-cursor=\"true\"]',\n );\n btn?.focus();\n }, [state.cursor]);\n\n const handleKeyDown = useCallback(\n (e: Parameters<NonNullable<CalendarProps[\"onKeyDown\"]>>[0]) => {\n const action = keyToAction(e.key);\n if (action === undefined) return;\n e.preventDefault();\n switch (action) {\n case \"prev\":\n goPrev();\n break;\n case \"next\":\n goNext();\n break;\n default:\n moveCursor(action);\n }\n },\n [moveCursor, goPrev, goNext],\n );\n\n return (\n <Calendar\n ref={rootRef}\n year={state.year}\n month={state.month}\n locale={state.options.locale}\n weekStart={state.options.weekStart}\n highlight={state.options.highlight}\n range={state.options.range}\n today={state.options.today}\n isDateDisabled={isDateDisabled}\n theme={theme}\n colorScheme={colorScheme}\n size={size}\n responsive={responsive}\n style={style}\n interactive\n renderCell={renderCell}\n cellData={cellData}\n selectedDate={hook.selectedDate}\n cursorDate={hook.cursorDate}\n hoveredDate={hook.hoveredDate}\n rangePreview={rangePreview}\n onDateClick={handleDateClick}\n onDateHover={handleDateHover}\n onDateLeave={handleDateLeave}\n onKeyDown={handleKeyDown}\n />\n );\n}\n"],"mappings":";;;;;;;AA2BA,SAAgB,eAAe,MAAY,SAAmC;CAC5E,MAAM,QAAQ,qBAAqB,MAAM,OAAO;CAChD,MAAM,UAAoB,CAAC;CAC3B,IAAI,MAAM,WAAW,QAAQ,KAAK,YAAY;CAC9C,IAAI,MAAM,SAAS,QAAQ,KAAK,UAAU;CAC1C,IAAI,MAAM,aAAa,QAAQ,KAAK,cAAc;CAClD,IAAI,MAAM,WAAW,QAAQ,KAAK,aAAa;CAC/C,IACE,QAAQ,iBAAiB,KAAA,KACzB,cAAc,MAAM,QAAQ,YAAY,GAExC,QAAQ,KAAK,qBAAqB;CACpC,IAAI,MAAM,YAAY,QAAQ,KAAK,aAAa;CAChD,IAAI,QAAQ,eAAe,QAAQ,UAAU,MAAM,QAAQ,WAAW,GACpE,QAAQ,KAAK,YAAY;CAC3B,IAAI,QAAQ,YAAY,QAAQ,UAAU,MAAM,QAAQ,QAAQ,GAC9D,QAAQ,KAAK,aAAa;CAC5B,IAAI,QAAQ,cAAc,QAAQ,UAAU,MAAM,QAAQ,UAAU,GAClE,QAAQ,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A,MAAM,kBAAkB,kBAAkB;EACxC,eAAe,IAAI;EACnB,cAAc;CAChB,GAAG,CAAC,gBAAgB,WAAW,CAAC;CAGhC,MAAM,eAAe,kBAAkB,KAAK,cAAc,KAAK,WAAW;CAG1E,MAAM,gBAAgB,OAAO,MAAM,MAAM;CACzC,gBAAgB;EACd,MAAM,OAAO,cAAc;EAC3B,cAAc,UAAU,MAAM;EAC9B,IAAI,SAAS,MAAM,QAAQ;EAI3B,CAHY,QAAQ,SAAS,cAC3B,wBACF,EAAA,EACK,MAAM;CACb,GAAG,CAAC,MAAM,MAAM,CAAC;CAEjB,MAAM,gBAAgB,aACnB,MAA8D;EAC7D,MAAM,SAAS,YAAY,EAAE,GAAG;EAChC,IAAI,WAAW,KAAA,GAAW;EAC1B,EAAE,eAAe;EACjB,QAAQ,QAAR;GACE,KAAK;IACH,OAAO;IACP;GACF,KAAK;IACH,OAAO;IACP;GACF,SACE,WAAW,MAAM;EACrB;CACF,GACA;EAAC;EAAY;EAAQ;CAAM,CAC7B;CAEA,OACE,oBAAC,UAAD;EACE,KAAK;EACL,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,QAAQ,MAAM,QAAQ;EACtB,WAAW,MAAM,QAAQ;EACzB,WAAW,MAAM,QAAQ;EACzB,OAAO,MAAM,QAAQ;EACrB,OAAO,MAAM,QAAQ;EACL;EACT;EACM;EACP;EACM;EACL;EACP,aAAA;EACY;EACF;EACV,cAAc,KAAK;EACnB,YAAY,KAAK;EACjB,aAAa,KAAK;EACJ;EACd,aAAa;EACb,aAAa;EACb,aAAa;EACb,WAAW;CACZ,CAAA;AAEL"}
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@typescript-calendar-lib/react",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
+ "description": "React 19 calendar components with CSS themes and color schemes",
4
5
  "type": "module",
5
6
  "repository": {
6
7
  "type": "git",
7
- "url": "https://github.com/nazozokc/typescript-calendar-lib"
8
+ "url": "https://github.com/nazozokc/typescript-calendar-lib",
9
+ "directory": "packages/react"
8
10
  },
9
11
  "main": "./dist/index.js",
10
12
  "types": "./dist/index.d.ts",
11
13
  "exports": {
12
14
  ".": {
13
15
  "types": "./dist/index.d.ts",
14
- "development": "./src/index.tsx",
15
16
  "default": "./dist/index.js"
16
17
  },
17
18
  "./calendar.css": "./dist/calendar.css"
@@ -19,22 +20,30 @@
19
20
  "files": [
20
21
  "dist"
21
22
  ],
23
+ "keywords": [
24
+ "calendar",
25
+ "react",
26
+ "component",
27
+ "ui"
28
+ ],
29
+ "license": "MIT",
22
30
  "dependencies": {
23
- "@typescript-calendar-lib/core": "0.4.1",
24
- "@typescript-calendar-lib/tui": "0.4.1"
31
+ "@typescript-calendar-lib/core": "0.5.0",
32
+ "@typescript-calendar-lib/tui": "0.5.0",
33
+ "@typescript-calendar-lib/web": "0.5.0"
25
34
  },
26
35
  "devDependencies": {
27
36
  "@testing-library/react": "^16",
28
- "@tsdown/css": "^0.23.0",
29
37
  "@types/react": "^19",
30
- "jsdom": "^26",
31
- "react-dom": "19.2.8",
38
+ "jsdom": "^30",
39
+ "react": "19.3.0",
40
+ "react-dom": "19.3.0",
32
41
  "vitest": "^5"
33
42
  },
34
43
  "peerDependencies": {
35
44
  "react": "^19"
36
45
  },
37
46
  "scripts": {
38
- "build": "tsdown"
47
+ "build": "tsdown && cp ../web/dist/calendar.css dist/calendar.css"
39
48
  }
40
49
  }