react-yearly-calendar-grid 0.4.0 → 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.ja.md +227 -0
- package/README.md +101 -58
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.ja.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# react-yearly-calendar-grid
|
|
2
|
+
|
|
3
|
+
年間カレンダーを表示するReactコンポーネント。ドラッグ&ドロップでイベントの移動・リサイズが可能。
|
|
4
|
+
|
|
5
|
+
[English](./README.md)
|
|
6
|
+
|
|
7
|
+
## インストール
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install react-yearly-calendar-grid
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 基本的な使い方
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { YearlyCalendar, CalendarEvent } from 'react-yearly-calendar-grid';
|
|
17
|
+
|
|
18
|
+
const events: CalendarEvent[] = [
|
|
19
|
+
{
|
|
20
|
+
id: '1',
|
|
21
|
+
date: new Date(2026, 0, 15),
|
|
22
|
+
title: '会議',
|
|
23
|
+
category: 'work',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: '2',
|
|
27
|
+
date: new Date(2026, 1, 10),
|
|
28
|
+
endDate: new Date(2026, 1, 14),
|
|
29
|
+
title: '出張',
|
|
30
|
+
category: 'travel',
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const categoryColors = {
|
|
35
|
+
work: '#2563eb',
|
|
36
|
+
travel: '#16a34a',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function App() {
|
|
40
|
+
return (
|
|
41
|
+
<div style={{ height: '100vh' }}>
|
|
42
|
+
<YearlyCalendar
|
|
43
|
+
year={2026}
|
|
44
|
+
events={events}
|
|
45
|
+
categoryColors={categoryColors}
|
|
46
|
+
onEventClick={(event) => console.log('Clicked:', event)}
|
|
47
|
+
onDateClick={(date, events) => console.log('Date:', date, events)}
|
|
48
|
+
onEventMove={(event, newStart, newEnd) => {
|
|
49
|
+
console.log('Moved:', event.title, 'to', newStart);
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Props
|
|
58
|
+
|
|
59
|
+
| Prop | 型 | 必須 | 説明 |
|
|
60
|
+
|------|-----|------|------|
|
|
61
|
+
| `year` | `number` | ○ | 表示する年 |
|
|
62
|
+
| `events` | `CalendarEvent[]` | - | イベント配列 |
|
|
63
|
+
| `holidays` | `Holiday[]` | - | 祝日配列 |
|
|
64
|
+
| `categoryColors` | `Record<string, string>` | - | カテゴリごとの色 |
|
|
65
|
+
| `theme` | `ThemeColors` | - | テーマカラー設定 |
|
|
66
|
+
| `highlightRange` | `{ start: Date; end: Date } \| null` | - | ハイライトする日付範囲 |
|
|
67
|
+
| `onDateClick` | `(date: Date, events: CalendarEvent[]) => void` | - | 日付クリック時 |
|
|
68
|
+
| `onDateDoubleClick` | `(date: Date, events: CalendarEvent[]) => void` | - | 日付ダブルクリック時 |
|
|
69
|
+
| `onDateRangeSelect` | `(startDate: Date, endDate: Date) => void` | - | 日付範囲選択時 |
|
|
70
|
+
| `onEventClick` | `(event: CalendarEvent) => void` | - | イベントクリック時 |
|
|
71
|
+
| `onEventMove` | `(event, newStartDate, newEndDate) => void` | - | イベント移動/リサイズ時 |
|
|
72
|
+
|
|
73
|
+
## CalendarEvent
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
interface CalendarEvent {
|
|
77
|
+
id: string; // 一意のID
|
|
78
|
+
date: Date; // 開始日
|
|
79
|
+
endDate?: Date; // 終了日(複数日イベントの場合)
|
|
80
|
+
title: string; // タイトル
|
|
81
|
+
color?: string; // 個別の色(categoryColorsより優先)
|
|
82
|
+
category?: string; // カテゴリ(categoryColorsで色を指定)
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Holiday
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
interface Holiday {
|
|
90
|
+
date: Date; // 祝日の日付
|
|
91
|
+
name: string; // 祝日名
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 祝日の使用例
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { YearlyCalendar, Holiday } from 'react-yearly-calendar-grid';
|
|
99
|
+
|
|
100
|
+
const holidays: Holiday[] = [
|
|
101
|
+
{ date: new Date(2026, 0, 1), name: '元日' },
|
|
102
|
+
{ date: new Date(2026, 0, 12), name: '成人の日' },
|
|
103
|
+
{ date: new Date(2026, 1, 11), name: '建国記念の日' },
|
|
104
|
+
{ date: new Date(2026, 1, 23), name: '天皇誕生日' },
|
|
105
|
+
{ date: new Date(2026, 2, 20), name: '春分の日' },
|
|
106
|
+
{ date: new Date(2026, 3, 29), name: '昭和の日' },
|
|
107
|
+
{ date: new Date(2026, 4, 3), name: '憲法記念日' },
|
|
108
|
+
{ date: new Date(2026, 4, 4), name: 'みどりの日' },
|
|
109
|
+
{ date: new Date(2026, 4, 5), name: 'こどもの日' },
|
|
110
|
+
{ date: new Date(2026, 6, 20), name: '海の日' },
|
|
111
|
+
{ date: new Date(2026, 7, 11), name: '山の日' },
|
|
112
|
+
{ date: new Date(2026, 8, 21), name: '敬老の日' },
|
|
113
|
+
{ date: new Date(2026, 8, 23), name: '秋分の日' },
|
|
114
|
+
{ date: new Date(2026, 9, 12), name: 'スポーツの日' },
|
|
115
|
+
{ date: new Date(2026, 10, 3), name: '文化の日' },
|
|
116
|
+
{ date: new Date(2026, 10, 23), name: '勤労感謝の日' },
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
function App() {
|
|
120
|
+
return (
|
|
121
|
+
<YearlyCalendar
|
|
122
|
+
year={2026}
|
|
123
|
+
holidays={holidays}
|
|
124
|
+
theme={{
|
|
125
|
+
bgHoliday: '#fef2f2', // 祝日の背景色
|
|
126
|
+
}}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 機能
|
|
133
|
+
|
|
134
|
+
### ドラッグ&ドロップ
|
|
135
|
+
イベントをドラッグして別の日に移動できます。複数日イベントは期間を維持したまま移動します。
|
|
136
|
+
|
|
137
|
+
### リサイズ
|
|
138
|
+
複数日イベントの上端/下端をドラッグして期間を伸縮できます。
|
|
139
|
+
|
|
140
|
+
### 月またぎ表示
|
|
141
|
+
複数月にまたがるイベントは各月に連続して表示されます。
|
|
142
|
+
|
|
143
|
+
### 日付範囲選択
|
|
144
|
+
日付をドラッグして範囲を選択できます。
|
|
145
|
+
|
|
146
|
+
## テーマカスタマイズ
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
<YearlyCalendar
|
|
150
|
+
year={2026}
|
|
151
|
+
events={events}
|
|
152
|
+
theme={{
|
|
153
|
+
bgSunday: '#ffe4e6', // 日曜日の背景色
|
|
154
|
+
bgSaturday: '#e0f2fe', // 土曜日の背景色
|
|
155
|
+
bgHoliday: '#fef2f2', // 祝日の背景色
|
|
156
|
+
buttonPrimary: '#059669', // ボタン色
|
|
157
|
+
tooltipBg: '#1f2937', // ツールチップ背景
|
|
158
|
+
}}
|
|
159
|
+
/>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### ThemeColors
|
|
163
|
+
|
|
164
|
+
| プロパティ | 説明 | デフォルト |
|
|
165
|
+
|-----------|------|-----------|
|
|
166
|
+
| `bgWhite` | 通常セル背景 | `#ffffff` |
|
|
167
|
+
| `bgGray50` | ホバー時背景 | `#f9fafb` |
|
|
168
|
+
| `bgGray100` | ヘッダー背景 | `#f3f4f6` |
|
|
169
|
+
| `bgSunday` | 日曜日背景 | `#fef2f2` |
|
|
170
|
+
| `bgSaturday` | 土曜日背景 | `#eff6ff` |
|
|
171
|
+
| `bgHoliday` | 祝日背景 | `#fef2f2` |
|
|
172
|
+
| `bgDropHighlight` | ドロップ先ハイライト | `rgba(191, 219, 254, 0.5)` |
|
|
173
|
+
| `borderDefault` | ボーダー色 | `#d1d5db` |
|
|
174
|
+
| `borderDropHighlight` | ドロップ先ボーダー | `#3b82f6` |
|
|
175
|
+
| `textPrimary` | メインテキスト | `#111827` |
|
|
176
|
+
| `textSecondary` | サブテキスト | `#4b5563` |
|
|
177
|
+
| `textMuted` | 薄いテキスト | `#6b7280` |
|
|
178
|
+
| `tooltipBg` | ツールチップ背景 | `#111827` |
|
|
179
|
+
| `tooltipText` | ツールチップ文字 | `#ffffff` |
|
|
180
|
+
| `buttonPrimary` | ボタン背景 | `#2563eb` |
|
|
181
|
+
| `buttonPrimaryHover` | ボタンホバー | `#1d4ed8` |
|
|
182
|
+
| `floatingDateBg` | ドラッグ中日付表示 | `#2563eb` |
|
|
183
|
+
| `resizeFloatingBg` | リサイズ中日付表示 | `#9333ea` |
|
|
184
|
+
|
|
185
|
+
## イベント移動の実装例
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
import { useState, useCallback } from 'react';
|
|
189
|
+
import { YearlyCalendar, CalendarEvent } from 'react-yearly-calendar-grid';
|
|
190
|
+
|
|
191
|
+
function App() {
|
|
192
|
+
const [events, setEvents] = useState<CalendarEvent[]>([
|
|
193
|
+
{ id: '1', date: new Date(2026, 0, 15), title: '予定1' },
|
|
194
|
+
]);
|
|
195
|
+
|
|
196
|
+
const handleEventMove = useCallback(
|
|
197
|
+
(event: CalendarEvent, newStartDate: Date, newEndDate: Date | undefined) => {
|
|
198
|
+
setEvents((prev) =>
|
|
199
|
+
prev.map((e) =>
|
|
200
|
+
e.id === event.id
|
|
201
|
+
? { ...e, date: newStartDate, endDate: newEndDate }
|
|
202
|
+
: e
|
|
203
|
+
)
|
|
204
|
+
);
|
|
205
|
+
},
|
|
206
|
+
[]
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<YearlyCalendar
|
|
211
|
+
year={2026}
|
|
212
|
+
events={events}
|
|
213
|
+
onEventMove={handleEventMove}
|
|
214
|
+
/>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## 注意点
|
|
220
|
+
|
|
221
|
+
- コンテナに高さを指定してください(`height: 100vh` など)
|
|
222
|
+
- カレンダーは親要素いっぱいに広がります
|
|
223
|
+
- 依存ライブラリなし(React/ReactDOM のみ peerDependency)
|
|
224
|
+
|
|
225
|
+
## License
|
|
226
|
+
|
|
227
|
+
MIT
|
package/README.md
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# react-yearly-calendar-grid
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A React component that displays a yearly calendar grid. Supports drag & drop for moving and resizing events.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[Japanese / 日本語](./README.ja.md)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
10
|
npm install react-yearly-calendar-grid
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## Basic Usage
|
|
12
14
|
|
|
13
15
|
```tsx
|
|
14
16
|
import { YearlyCalendar, CalendarEvent } from 'react-yearly-calendar-grid';
|
|
@@ -17,14 +19,14 @@ const events: CalendarEvent[] = [
|
|
|
17
19
|
{
|
|
18
20
|
id: '1',
|
|
19
21
|
date: new Date(2026, 0, 15),
|
|
20
|
-
title: '
|
|
22
|
+
title: 'Meeting',
|
|
21
23
|
category: 'work',
|
|
22
24
|
},
|
|
23
25
|
{
|
|
24
26
|
id: '2',
|
|
25
27
|
date: new Date(2026, 1, 10),
|
|
26
28
|
endDate: new Date(2026, 1, 14),
|
|
27
|
-
title: '
|
|
29
|
+
title: 'Business Trip',
|
|
28
30
|
category: 'travel',
|
|
29
31
|
},
|
|
30
32
|
];
|
|
@@ -54,78 +56,119 @@ function App() {
|
|
|
54
56
|
|
|
55
57
|
## Props
|
|
56
58
|
|
|
57
|
-
| Prop |
|
|
58
|
-
|
|
59
|
-
| `year` | `number` |
|
|
60
|
-
| `events` | `CalendarEvent[]` |
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
59
|
+
| Prop | Type | Required | Description |
|
|
60
|
+
|------|------|----------|-------------|
|
|
61
|
+
| `year` | `number` | Yes | The year to display |
|
|
62
|
+
| `events` | `CalendarEvent[]` | No | Array of events |
|
|
63
|
+
| `holidays` | `Holiday[]` | No | Array of holidays |
|
|
64
|
+
| `categoryColors` | `Record<string, string>` | No | Colors for each category |
|
|
65
|
+
| `theme` | `ThemeColors` | No | Theme color settings |
|
|
66
|
+
| `highlightRange` | `{ start: Date; end: Date } \| null` | No | Date range to highlight |
|
|
67
|
+
| `onDateClick` | `(date: Date, events: CalendarEvent[]) => void` | No | Called when a date is clicked |
|
|
68
|
+
| `onDateDoubleClick` | `(date: Date, events: CalendarEvent[]) => void` | No | Called when a date is double-clicked |
|
|
69
|
+
| `onDateRangeSelect` | `(startDate: Date, endDate: Date) => void` | No | Called when a date range is selected |
|
|
70
|
+
| `onEventClick` | `(event: CalendarEvent) => void` | No | Called when an event is clicked |
|
|
71
|
+
| `onEventMove` | `(event, newStartDate, newEndDate) => void` | No | Called when an event is moved or resized |
|
|
66
72
|
|
|
67
73
|
## CalendarEvent
|
|
68
74
|
|
|
69
75
|
```ts
|
|
70
76
|
interface CalendarEvent {
|
|
71
|
-
id: string; //
|
|
72
|
-
date: Date; //
|
|
73
|
-
endDate?: Date; //
|
|
74
|
-
title: string; //
|
|
75
|
-
color?: string; //
|
|
76
|
-
category?: string; //
|
|
77
|
+
id: string; // Unique ID
|
|
78
|
+
date: Date; // Start date
|
|
79
|
+
endDate?: Date; // End date (for multi-day events)
|
|
80
|
+
title: string; // Title
|
|
81
|
+
color?: string; // Individual color (overrides categoryColors)
|
|
82
|
+
category?: string; // Category (use categoryColors to specify color)
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Holiday
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
interface Holiday {
|
|
90
|
+
date: Date; // Holiday date
|
|
91
|
+
name: string; // Holiday name
|
|
77
92
|
}
|
|
78
93
|
```
|
|
79
94
|
|
|
80
|
-
|
|
95
|
+
### Holidays Example
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { YearlyCalendar, Holiday } from 'react-yearly-calendar-grid';
|
|
99
|
+
|
|
100
|
+
const holidays: Holiday[] = [
|
|
101
|
+
{ date: new Date(2026, 0, 1), name: "New Year's Day" },
|
|
102
|
+
{ date: new Date(2026, 11, 25), name: 'Christmas' },
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
function App() {
|
|
106
|
+
return (
|
|
107
|
+
<YearlyCalendar
|
|
108
|
+
year={2026}
|
|
109
|
+
holidays={holidays}
|
|
110
|
+
theme={{
|
|
111
|
+
bgHoliday: '#fef2f2', // Holiday background color
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Features
|
|
119
|
+
|
|
120
|
+
### Drag & Drop
|
|
121
|
+
Drag events to move them to different dates. Multi-day events maintain their duration when moved.
|
|
81
122
|
|
|
82
|
-
###
|
|
83
|
-
|
|
123
|
+
### Resize
|
|
124
|
+
Drag the top or bottom edge of multi-day events to extend or shorten their duration.
|
|
84
125
|
|
|
85
|
-
###
|
|
86
|
-
|
|
126
|
+
### Cross-Month Display
|
|
127
|
+
Events spanning multiple months are displayed continuously across each month.
|
|
87
128
|
|
|
88
|
-
###
|
|
89
|
-
|
|
129
|
+
### Date Range Selection
|
|
130
|
+
Click and drag across dates to select a date range.
|
|
90
131
|
|
|
91
|
-
##
|
|
132
|
+
## Theme Customization
|
|
92
133
|
|
|
93
134
|
```tsx
|
|
94
135
|
<YearlyCalendar
|
|
95
136
|
year={2026}
|
|
96
137
|
events={events}
|
|
97
138
|
theme={{
|
|
98
|
-
bgSunday: '#ffe4e6', //
|
|
99
|
-
bgSaturday: '#e0f2fe', //
|
|
100
|
-
|
|
101
|
-
|
|
139
|
+
bgSunday: '#ffe4e6', // Sunday background color
|
|
140
|
+
bgSaturday: '#e0f2fe', // Saturday background color
|
|
141
|
+
bgHoliday: '#fef2f2', // Holiday background color
|
|
142
|
+
buttonPrimary: '#059669', // Button color
|
|
143
|
+
tooltipBg: '#1f2937', // Tooltip background
|
|
102
144
|
}}
|
|
103
145
|
/>
|
|
104
146
|
```
|
|
105
147
|
|
|
106
148
|
### ThemeColors
|
|
107
149
|
|
|
108
|
-
|
|
|
109
|
-
|
|
110
|
-
| `bgWhite` |
|
|
111
|
-
| `bgGray50` |
|
|
112
|
-
| `bgGray100` |
|
|
113
|
-
| `bgSunday` |
|
|
114
|
-
| `bgSaturday` |
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
|
|
128
|
-
|
|
150
|
+
| Property | Description | Default |
|
|
151
|
+
|----------|-------------|---------|
|
|
152
|
+
| `bgWhite` | Normal cell background | `#ffffff` |
|
|
153
|
+
| `bgGray50` | Hover background | `#f9fafb` |
|
|
154
|
+
| `bgGray100` | Header background | `#f3f4f6` |
|
|
155
|
+
| `bgSunday` | Sunday background | `#fef2f2` |
|
|
156
|
+
| `bgSaturday` | Saturday background | `#eff6ff` |
|
|
157
|
+
| `bgHoliday` | Holiday background | `#fef2f2` |
|
|
158
|
+
| `bgDropHighlight` | Drop target highlight | `rgba(191, 219, 254, 0.5)` |
|
|
159
|
+
| `borderDefault` | Border color | `#d1d5db` |
|
|
160
|
+
| `borderDropHighlight` | Drop target border | `#3b82f6` |
|
|
161
|
+
| `textPrimary` | Main text color | `#111827` |
|
|
162
|
+
| `textSecondary` | Secondary text color | `#4b5563` |
|
|
163
|
+
| `textMuted` | Muted text color | `#6b7280` |
|
|
164
|
+
| `tooltipBg` | Tooltip background | `#111827` |
|
|
165
|
+
| `tooltipText` | Tooltip text color | `#ffffff` |
|
|
166
|
+
| `buttonPrimary` | Button background | `#2563eb` |
|
|
167
|
+
| `buttonPrimaryHover` | Button hover background | `#1d4ed8` |
|
|
168
|
+
| `floatingDateBg` | Dragging date display background | `#2563eb` |
|
|
169
|
+
| `resizeFloatingBg` | Resizing date display background | `#9333ea` |
|
|
170
|
+
|
|
171
|
+
## Event Move Implementation Example
|
|
129
172
|
|
|
130
173
|
```tsx
|
|
131
174
|
import { useState, useCallback } from 'react';
|
|
@@ -133,7 +176,7 @@ import { YearlyCalendar, CalendarEvent } from 'react-yearly-calendar-grid';
|
|
|
133
176
|
|
|
134
177
|
function App() {
|
|
135
178
|
const [events, setEvents] = useState<CalendarEvent[]>([
|
|
136
|
-
{ id: '1', date: new Date(2026, 0, 15), title: '
|
|
179
|
+
{ id: '1', date: new Date(2026, 0, 15), title: 'Event 1' },
|
|
137
180
|
]);
|
|
138
181
|
|
|
139
182
|
const handleEventMove = useCallback(
|
|
@@ -159,11 +202,11 @@ function App() {
|
|
|
159
202
|
}
|
|
160
203
|
```
|
|
161
204
|
|
|
162
|
-
##
|
|
205
|
+
## Notes
|
|
163
206
|
|
|
164
|
-
-
|
|
165
|
-
-
|
|
166
|
-
-
|
|
207
|
+
- Set a height on the container (e.g., `height: 100vh`)
|
|
208
|
+
- The calendar expands to fill its parent element
|
|
209
|
+
- No external dependencies (only React/ReactDOM as peerDependencies)
|
|
167
210
|
|
|
168
211
|
## License
|
|
169
212
|
|
package/dist/index.d.mts
CHANGED
|
@@ -9,12 +9,17 @@ interface CalendarEvent {
|
|
|
9
9
|
color?: string;
|
|
10
10
|
category?: string;
|
|
11
11
|
}
|
|
12
|
+
interface Holiday {
|
|
13
|
+
date: Date;
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
12
16
|
interface ThemeColors {
|
|
13
17
|
bgWhite?: string;
|
|
14
18
|
bgGray50?: string;
|
|
15
19
|
bgGray100?: string;
|
|
16
20
|
bgSunday?: string;
|
|
17
21
|
bgSaturday?: string;
|
|
22
|
+
bgHoliday?: string;
|
|
18
23
|
bgDropHighlight?: string;
|
|
19
24
|
borderDefault?: string;
|
|
20
25
|
borderDropHighlight?: string;
|
|
@@ -32,6 +37,7 @@ interface ThemeColors {
|
|
|
32
37
|
interface YearlyCalendarProps {
|
|
33
38
|
year: number;
|
|
34
39
|
events?: CalendarEvent[];
|
|
40
|
+
holidays?: Holiday[];
|
|
35
41
|
onDateClick?: (date: Date, events: CalendarEvent[]) => void;
|
|
36
42
|
onDateDoubleClick?: (date: Date, events: CalendarEvent[]) => void;
|
|
37
43
|
onDateRangeSelect?: (startDate: Date, endDate: Date) => void;
|
|
@@ -53,7 +59,7 @@ interface DayCellProps {
|
|
|
53
59
|
onEventClick?: (event: CalendarEvent) => void;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
declare function YearlyCalendar({ year, events, onDateClick, onDateDoubleClick, onDateRangeSelect, onEventClick, onEventMove, highlightRange, categoryColors, theme: customTheme, }: YearlyCalendarProps): react_jsx_runtime.JSX.Element;
|
|
62
|
+
declare function YearlyCalendar({ year, events, holidays, onDateClick, onDateDoubleClick, onDateRangeSelect, onEventClick, onEventMove, highlightRange, categoryColors, theme: customTheme, }: YearlyCalendarProps): react_jsx_runtime.JSX.Element;
|
|
57
63
|
|
|
58
64
|
declare const defaultTheme: Required<ThemeColors>;
|
|
59
65
|
declare function mergeTheme(custom?: ThemeColors): Required<ThemeColors>;
|
|
@@ -98,4 +104,4 @@ declare function createStyles(theme: Required<ThemeColors>): {
|
|
|
98
104
|
truncate: CSSProperties;
|
|
99
105
|
};
|
|
100
106
|
|
|
101
|
-
export { type CalendarEvent, type DayCellProps, type ThemeColors, YearlyCalendar, type YearlyCalendarProps, createStyles, defaultTheme, mergeTheme };
|
|
107
|
+
export { type CalendarEvent, type DayCellProps, type Holiday, type ThemeColors, YearlyCalendar, type YearlyCalendarProps, createStyles, defaultTheme, mergeTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,12 +9,17 @@ interface CalendarEvent {
|
|
|
9
9
|
color?: string;
|
|
10
10
|
category?: string;
|
|
11
11
|
}
|
|
12
|
+
interface Holiday {
|
|
13
|
+
date: Date;
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
12
16
|
interface ThemeColors {
|
|
13
17
|
bgWhite?: string;
|
|
14
18
|
bgGray50?: string;
|
|
15
19
|
bgGray100?: string;
|
|
16
20
|
bgSunday?: string;
|
|
17
21
|
bgSaturday?: string;
|
|
22
|
+
bgHoliday?: string;
|
|
18
23
|
bgDropHighlight?: string;
|
|
19
24
|
borderDefault?: string;
|
|
20
25
|
borderDropHighlight?: string;
|
|
@@ -32,6 +37,7 @@ interface ThemeColors {
|
|
|
32
37
|
interface YearlyCalendarProps {
|
|
33
38
|
year: number;
|
|
34
39
|
events?: CalendarEvent[];
|
|
40
|
+
holidays?: Holiday[];
|
|
35
41
|
onDateClick?: (date: Date, events: CalendarEvent[]) => void;
|
|
36
42
|
onDateDoubleClick?: (date: Date, events: CalendarEvent[]) => void;
|
|
37
43
|
onDateRangeSelect?: (startDate: Date, endDate: Date) => void;
|
|
@@ -53,7 +59,7 @@ interface DayCellProps {
|
|
|
53
59
|
onEventClick?: (event: CalendarEvent) => void;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
declare function YearlyCalendar({ year, events, onDateClick, onDateDoubleClick, onDateRangeSelect, onEventClick, onEventMove, highlightRange, categoryColors, theme: customTheme, }: YearlyCalendarProps): react_jsx_runtime.JSX.Element;
|
|
62
|
+
declare function YearlyCalendar({ year, events, holidays, onDateClick, onDateDoubleClick, onDateRangeSelect, onEventClick, onEventMove, highlightRange, categoryColors, theme: customTheme, }: YearlyCalendarProps): react_jsx_runtime.JSX.Element;
|
|
57
63
|
|
|
58
64
|
declare const defaultTheme: Required<ThemeColors>;
|
|
59
65
|
declare function mergeTheme(custom?: ThemeColors): Required<ThemeColors>;
|
|
@@ -98,4 +104,4 @@ declare function createStyles(theme: Required<ThemeColors>): {
|
|
|
98
104
|
truncate: CSSProperties;
|
|
99
105
|
};
|
|
100
106
|
|
|
101
|
-
export { type CalendarEvent, type DayCellProps, type ThemeColors, YearlyCalendar, type YearlyCalendarProps, createStyles, defaultTheme, mergeTheme };
|
|
107
|
+
export { type CalendarEvent, type DayCellProps, type Holiday, type ThemeColors, YearlyCalendar, type YearlyCalendarProps, createStyles, defaultTheme, mergeTheme };
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var defaultTheme = {
|
|
|
32
32
|
bgGray100: "#f3f4f6",
|
|
33
33
|
bgSunday: "#fef2f2",
|
|
34
34
|
bgSaturday: "#eff6ff",
|
|
35
|
+
bgHoliday: "#fef2f2",
|
|
35
36
|
bgDropHighlight: "rgba(191, 219, 254, 0.5)",
|
|
36
37
|
// ボーダー
|
|
37
38
|
borderDefault: "#d1d5db",
|
|
@@ -337,9 +338,10 @@ function createStyles(theme) {
|
|
|
337
338
|
}
|
|
338
339
|
};
|
|
339
340
|
}
|
|
340
|
-
function getCellBackgroundColor(theme, isValidDay, isSunday2, isSaturday2, isHovered) {
|
|
341
|
+
function getCellBackgroundColor(theme, isValidDay, isSunday2, isSaturday2, isHovered, isHoliday = false) {
|
|
341
342
|
if (!isValidDay) return theme.bgGray100;
|
|
342
343
|
if (isHovered) return theme.bgGray50;
|
|
344
|
+
if (isHoliday) return theme.bgHoliday;
|
|
343
345
|
if (isSunday2) return theme.bgSunday;
|
|
344
346
|
if (isSaturday2) return theme.bgSaturday;
|
|
345
347
|
return theme.bgWhite;
|
|
@@ -412,6 +414,7 @@ function calculateLanes(spans) {
|
|
|
412
414
|
function YearlyCalendar({
|
|
413
415
|
year,
|
|
414
416
|
events = [],
|
|
417
|
+
holidays = [],
|
|
415
418
|
onDateClick,
|
|
416
419
|
onDateDoubleClick,
|
|
417
420
|
onDateRangeSelect,
|
|
@@ -458,6 +461,18 @@ function YearlyCalendar({
|
|
|
458
461
|
const [rangeSelectionStart, setRangeSelectionStart] = react.useState(null);
|
|
459
462
|
const [rangeSelectionEnd, setRangeSelectionEnd] = react.useState(null);
|
|
460
463
|
const isRangeSelecting = rangeSelectionStart !== null;
|
|
464
|
+
const holidayMap = react.useMemo(() => {
|
|
465
|
+
const map = /* @__PURE__ */ new Map();
|
|
466
|
+
holidays.forEach((holiday) => {
|
|
467
|
+
const dateKey = `${holiday.date.getFullYear()}-${holiday.date.getMonth()}-${holiday.date.getDate()}`;
|
|
468
|
+
map.set(dateKey, holiday);
|
|
469
|
+
});
|
|
470
|
+
return map;
|
|
471
|
+
}, [holidays]);
|
|
472
|
+
const isHoliday = (month, day) => {
|
|
473
|
+
const dateKey = `${year}-${month}-${day}`;
|
|
474
|
+
return holidayMap.has(dateKey);
|
|
475
|
+
};
|
|
461
476
|
const monthSpans = react.useMemo(() => {
|
|
462
477
|
const result = [];
|
|
463
478
|
for (let month = 0; month < 12; month++) {
|
|
@@ -830,6 +845,7 @@ function YearlyCalendar({
|
|
|
830
845
|
const isValidDay = day <= daysInMonth;
|
|
831
846
|
const sunday = isValidDay && isSunday(year, monthIndex, day);
|
|
832
847
|
const saturday = isValidDay && isSaturday(year, monthIndex, day);
|
|
848
|
+
const holiday = isValidDay && isHoliday(monthIndex, day);
|
|
833
849
|
const isHovered = (hoveredCell == null ? void 0 : hoveredCell.month) === monthIndex && (hoveredCell == null ? void 0 : hoveredCell.day) === day;
|
|
834
850
|
const isInRange = isValidDay && isInSelectionRange(monthIndex, day);
|
|
835
851
|
const isHighlighted = isValidDay && isInHighlightRange(monthIndex, day);
|
|
@@ -843,7 +859,8 @@ function YearlyCalendar({
|
|
|
843
859
|
isValidDay,
|
|
844
860
|
sunday,
|
|
845
861
|
saturday,
|
|
846
|
-
isHovered && isValidDay && !isRangeSelecting
|
|
862
|
+
isHovered && isValidDay && !isRangeSelecting,
|
|
863
|
+
holiday
|
|
847
864
|
),
|
|
848
865
|
cursor: isValidDay ? "pointer" : "default",
|
|
849
866
|
userSelect: "none"
|