react-modular-datepicker 0.0.2-canary.4 â 0.0.3-canary.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 +408 -1
- package/dist/adapters/dayjs.d.ts +21 -0
- package/dist/classNames.d.ts +67 -0
- package/dist/components/Calendar.d.ts +14 -0
- package/dist/components/CalendarHeader.d.ts +19 -0
- package/dist/components/Day.d.ts +13 -0
- package/dist/components/MonthSelection.d.ts +13 -0
- package/dist/components/YearSelection.d.ts +12 -0
- package/dist/i18n.d.ts +9 -0
- package/dist/index.css +1875 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +316 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types.d.ts +42 -0
- package/dist/useDates-D9EvVlhK.js +2 -0
- package/dist/useDates-D9EvVlhK.js.map +1 -0
- package/dist/useDates-DQabq6Ux.mjs +201 -0
- package/dist/useDates-DQabq6Ux.mjs.map +1 -0
- package/dist/useDates.d.ts +63 -0
- package/dist/useDates.js +1 -0
- package/dist/useDates.mjs +3 -0
- package/dist/utils.d.ts +42 -0
- package/dist/utils.js +2 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +169 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +96 -6
- package/.gitattributes +0 -2
- package/.github/workflows/release.yml +0 -59
- package/index.js +0 -5
- package/scripts/bump-version.js +0 -41
package/README.md
CHANGED
|
@@ -1,2 +1,409 @@
|
|
|
1
1
|
# react-modular-datepicker
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
A modular, lightweight, and type-safe React datepicker library. Whether you need a fully-featured calendar component or a headless hook to build your own UI, `react-modular-datepicker` has you covered.
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="./docs/images/hero-calendar.png" alt="react-modular-datepicker preview" width="320" />
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
## Strengths
|
|
10
|
+
|
|
11
|
+
- đī¸ **Headless & Modular**: Use the `useDates` hook for complete control over your UI, or the `Calendar` component for a beautiful, ready-to-use setup.
|
|
12
|
+
- đĒļ **Lightweight**: Small footprint with a pluggable adapter system (defaults to Day.js).
|
|
13
|
+
- đĄī¸ **Type-safe**: Written in TypeScript for a great developer experience.
|
|
14
|
+
- đ¨ **Fully Customizable**: Style everything via Tailwind CSS or custom class names.
|
|
15
|
+
- đ **Localized**: Easy internationalization support with `dayjs` or custom adapters.
|
|
16
|
+
- ⥠**Feature-rich**: Single, multiple, and range selection modes, min/max dates, disabled dates, and more.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## API Reference
|
|
21
|
+
|
|
22
|
+
### Imports
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import {
|
|
26
|
+
Calendar,
|
|
27
|
+
useDates,
|
|
28
|
+
Dates,
|
|
29
|
+
Day,
|
|
30
|
+
DayjsAdapter,
|
|
31
|
+
defaultAdapter
|
|
32
|
+
} from 'react-modular-datepicker';
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### `Calendar` Component
|
|
36
|
+
|
|
37
|
+
The primary component for a ready-to-use calendar.
|
|
38
|
+
|
|
39
|
+
| Prop | Type | Default | Description |
|
|
40
|
+
| :--- | :--- | :--- | :--- |
|
|
41
|
+
| `date` | `Date` | `new Date()` | The initial date/month to display. |
|
|
42
|
+
| `selected` | `Date \| Date[] \| Range` | `undefined` | The currently selected date(s). |
|
|
43
|
+
| `selectionMode` | `'single' \| 'range' \| 'multiple'` | `'single'` | The selection behavior. |
|
|
44
|
+
| `onChange` | `(selected: any) => void` | `undefined` | Callback triggered when the selection changes. |
|
|
45
|
+
| `minDate` | `Date` | `undefined` | The earliest selectable date. |
|
|
46
|
+
| `maxDate` | `Date` | `undefined` | The latest selectable date. |
|
|
47
|
+
| `disabledDates` | `Date[]` | `undefined` | An array of dates that should be disabled. |
|
|
48
|
+
| `monthsToDisplay` | `number` | `1` | Number of months to show simultaneously. |
|
|
49
|
+
| `firstDayOfWeek` | `number` | `0` | The first day of the week (0=Sun, 1=Mon, ...). |
|
|
50
|
+
| `showOutsideDays` | `boolean` | `false` | Whether to show days from the previous/next months. |
|
|
51
|
+
| `classNames` | `CalendarClassNames` | `undefined` | Custom classes for styling various parts of the UI. |
|
|
52
|
+
| `locale` | `string` | `undefined` | Locale for date formatting (e.g., 'fr', 'es'). |
|
|
53
|
+
| `translations` | `Partial<Translations>` | `undefined` | Custom translation strings for "Back" and "Forward". |
|
|
54
|
+
| `adapter` | `DateAdapter` | `defaultAdapter` | The date management adapter (e.g., DayjsAdapter). |
|
|
55
|
+
|
|
56
|
+
### `useDates` Hook
|
|
57
|
+
|
|
58
|
+
The logic core of the library. It handles selection, navigation, and grid generation.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
const {
|
|
62
|
+
calendars,
|
|
63
|
+
getDateProps,
|
|
64
|
+
getBackProps,
|
|
65
|
+
getForwardProps,
|
|
66
|
+
setOffset
|
|
67
|
+
} = useDates(props: UseDatesProps);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**`UseDatesProps`** includes all props from `Calendar` (except `classNames`, `locale`, `translations`) plus:
|
|
71
|
+
- `onDateSelected`: `(dateObj: DateObj, event: any) => void`
|
|
72
|
+
- `onOffsetChanged`: `(newOffset: number) => void`
|
|
73
|
+
- `modifiers`: `Record<string, (date: Date) => boolean>`
|
|
74
|
+
|
|
75
|
+
### Main Types
|
|
76
|
+
|
|
77
|
+
#### `DateObj`
|
|
78
|
+
Represents a single day in the calendar grid.
|
|
79
|
+
- `date`: `Date`
|
|
80
|
+
- `selected`: `boolean`
|
|
81
|
+
- `selectable`: `boolean`
|
|
82
|
+
- `today`: `boolean`
|
|
83
|
+
- `prevMonth`/`nextMonth`: `boolean` (if outside current month)
|
|
84
|
+
- `isRangeStart`/`isRangeEnd`/`isRangeBetween`/`isRangeHovering`: `boolean`
|
|
85
|
+
- `modifiers`: `string[]`
|
|
86
|
+
|
|
87
|
+
#### `Calendar`
|
|
88
|
+
Represents a month grid.
|
|
89
|
+
- `month`: `number` (0-11)
|
|
90
|
+
- `year`: `number`
|
|
91
|
+
- `weeks`: `(DateObj | null)[][]`
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Recipes
|
|
96
|
+
|
|
97
|
+
<details>
|
|
98
|
+
<summary><b>Basic Selection</b></summary>
|
|
99
|
+
A simple single-date selection calendar.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { Calendar } from 'react-modular-datepicker';
|
|
103
|
+
import 'react-modular-datepicker/dist/index.css';
|
|
104
|
+
|
|
105
|
+
function BasicExample() {
|
|
106
|
+
return <Calendar onChange={(date) => console.log(date)} />;
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
<br />
|
|
111
|
+
|
|
112
|
+
<img src="./docs/images/basic.png" alt="Basic Selection" width="500" />
|
|
113
|
+
|
|
114
|
+
</details>
|
|
115
|
+
|
|
116
|
+
<details>
|
|
117
|
+
<summary><b>Range Selection</b></summary>
|
|
118
|
+
Select a start and end date with a hover preview.
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
<Calendar
|
|
122
|
+
selectionMode="range"
|
|
123
|
+
monthsToDisplay={2}
|
|
124
|
+
onChange={(range) => console.log(range)}
|
|
125
|
+
/>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
<br />
|
|
129
|
+
|
|
130
|
+
<img src="./docs/images/range.png" alt="Range Selection" width="500" />
|
|
131
|
+
|
|
132
|
+
</details>
|
|
133
|
+
|
|
134
|
+
<details>
|
|
135
|
+
<summary><b>Multiple Selection</b></summary>
|
|
136
|
+
Select as many dates as you want.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
<Calendar
|
|
140
|
+
selectionMode="multiple"
|
|
141
|
+
onChange={(dates) => console.log(dates)}
|
|
142
|
+
/>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
<br />
|
|
146
|
+
|
|
147
|
+
<img src="./docs/images/multiple.png" alt="Multiple Selection" width="500" />
|
|
148
|
+
|
|
149
|
+
</details>
|
|
150
|
+
|
|
151
|
+
<details>
|
|
152
|
+
<summary><b>Headless Usage</b></summary>
|
|
153
|
+
Complete freedom over your UI using the `useDates` hook.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
const { calendars, getDateProps } = useDates({ selectionMode: 'single' });
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<div className="grid grid-cols-7">
|
|
160
|
+
{calendars[0].weeks.flat().map((dateObj, i) => (
|
|
161
|
+
dateObj ? (
|
|
162
|
+
<button key={i} {...getDateProps({ dateObj })}>
|
|
163
|
+
{dateObj.date.getDate()}
|
|
164
|
+
</button>
|
|
165
|
+
) : <div key={i} />
|
|
166
|
+
))}
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
<br />
|
|
172
|
+
|
|
173
|
+
<img src="./docs/images/headless.png" alt="Headless Usage" width="500" />
|
|
174
|
+
|
|
175
|
+
</details>
|
|
176
|
+
|
|
177
|
+
<details>
|
|
178
|
+
<summary><b>Custom Styling</b></summary>
|
|
179
|
+
Easily customize the look and feel using the `classNames` prop.
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
<Calendar
|
|
183
|
+
classNames={{
|
|
184
|
+
root: 'bg-stone-50 p-6 rounded-2xl border border-stone-200 shadow-lg text-stone-800',
|
|
185
|
+
monthYearLabel: 'font-serif text-stone-900 text-lg font-bold',
|
|
186
|
+
day: {
|
|
187
|
+
unselected: 'bg-white border border-stone-200 hover:bg-amber-100/50 text-stone-800',
|
|
188
|
+
selected: 'bg-amber-800 text-amber-50 font-bold',
|
|
189
|
+
}
|
|
190
|
+
}}
|
|
191
|
+
/>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
<br />
|
|
195
|
+
|
|
196
|
+
<img src="./docs/images/custom-styling.png" alt="Custom Styling" width="500" />
|
|
197
|
+
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
<details>
|
|
201
|
+
<summary><b>Localization & i18n</b></summary>
|
|
202
|
+
Easily customize language, month/weekday labels, and the first day of week.
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
<Calendar
|
|
206
|
+
firstDayOfWeek={1} // Start week on Monday
|
|
207
|
+
translations={{
|
|
208
|
+
months: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
|
|
209
|
+
weekdays: ['Dom', 'Lun', 'Mar', 'MiÊ', 'Jue', 'Vie', 'SÃĄb'],
|
|
210
|
+
}}
|
|
211
|
+
/>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
<br />
|
|
215
|
+
|
|
216
|
+
<img src="./docs/images/localization.png" alt="Localization & i18n" width="500" />
|
|
217
|
+
|
|
218
|
+
</details>
|
|
219
|
+
|
|
220
|
+
<details>
|
|
221
|
+
<summary><b>Form Integration</b></summary>
|
|
222
|
+
Integrate the calendar into a form or popup.
|
|
223
|
+
|
|
224
|
+
```tsx
|
|
225
|
+
const [date, setDate] = useState<Date | null>(null);
|
|
226
|
+
|
|
227
|
+
<div className="relative group">
|
|
228
|
+
<input
|
|
229
|
+
type="text"
|
|
230
|
+
readOnly
|
|
231
|
+
value={date ? date.toLocaleDateString() : ''}
|
|
232
|
+
placeholder="Pick a date"
|
|
233
|
+
/>
|
|
234
|
+
<div className="absolute top-full left-0 mt-2 z-50 invisible group-focus-within:visible">
|
|
235
|
+
<Calendar
|
|
236
|
+
selected={date}
|
|
237
|
+
onChange={(d) => setDate(d as Date)}
|
|
238
|
+
/>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
<br />
|
|
244
|
+
|
|
245
|
+
<img src="./docs/images/form-integration.png" alt="Form Integration" width="500" />
|
|
246
|
+
|
|
247
|
+
</details>
|
|
248
|
+
|
|
249
|
+
<details>
|
|
250
|
+
<summary><b>Custom Header & Footer</b></summary>
|
|
251
|
+
Customize header, footer, and day tooltips.
|
|
252
|
+
|
|
253
|
+
```tsx
|
|
254
|
+
<Calendar
|
|
255
|
+
selected={selected}
|
|
256
|
+
onChange={(val) => setSelected(val as Date)}
|
|
257
|
+
monthsToDisplay={2}
|
|
258
|
+
header={<div className="p-2 bg-blue-100 text-blue-800 font-bold text-center rounded-t-lg">My Header</div>}
|
|
259
|
+
footer={<div className="p-2 bg-gray-100 text-gray-600 text-sm text-center rounded-b-lg border-t">My Custom Footer</div>}
|
|
260
|
+
renderDayTooltip={(dateObj) => (
|
|
261
|
+
dateObj.date.getDate() === 15 ? 'Middle of the month!' : null
|
|
262
|
+
)}
|
|
263
|
+
/>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
<br />
|
|
267
|
+
|
|
268
|
+
<img src="./docs/images/custom-header-footer.png" alt="Custom Header & Footer" width="500" />
|
|
269
|
+
|
|
270
|
+
</details>
|
|
271
|
+
|
|
272
|
+
<details>
|
|
273
|
+
<summary><b>Min, Max & Disabled Dates</b></summary>
|
|
274
|
+
Restrict date selection with min/max bounds or specific disabled dates.
|
|
275
|
+
|
|
276
|
+
```tsx
|
|
277
|
+
<Calendar
|
|
278
|
+
selected={selected}
|
|
279
|
+
onChange={(val) => setSelected(val as Date)}
|
|
280
|
+
minDate={minDate}
|
|
281
|
+
maxDate={maxDate}
|
|
282
|
+
disabledDates={[disabledDate1, disabledDate2]}
|
|
283
|
+
/>
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
<br />
|
|
287
|
+
|
|
288
|
+
<img src="./docs/images/min-max-disabled.png" alt="Min, Max & Disabled Dates" width="500" />
|
|
289
|
+
|
|
290
|
+
</details>
|
|
291
|
+
|
|
292
|
+
<details>
|
|
293
|
+
<summary><b>Yearly View</b></summary>
|
|
294
|
+
Display an entire year at once by customizing the grid and `monthsToDisplay`.
|
|
295
|
+
|
|
296
|
+
```tsx
|
|
297
|
+
<Calendar
|
|
298
|
+
selected={selected}
|
|
299
|
+
onChange={(val) => setSelected(val as Date)}
|
|
300
|
+
monthsToDisplay={12}
|
|
301
|
+
classNames={{
|
|
302
|
+
calendarsContainer: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"
|
|
303
|
+
}}
|
|
304
|
+
/>
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
<br />
|
|
308
|
+
|
|
309
|
+
<img src="./docs/images/yearly.png" alt="Yearly View" width="500" />
|
|
310
|
+
|
|
311
|
+
</details>
|
|
312
|
+
|
|
313
|
+
<details>
|
|
314
|
+
<summary><b>Availability & Async Data</b></summary>
|
|
315
|
+
Fetch and display availability dynamically when the month changes.
|
|
316
|
+
|
|
317
|
+
```tsx
|
|
318
|
+
<Calendar
|
|
319
|
+
selected={selected}
|
|
320
|
+
onChange={(val) => setSelected(val as Date)}
|
|
321
|
+
onMonthChange={(date) => fetchAvailabilities(date)}
|
|
322
|
+
modifiers={{
|
|
323
|
+
available: (date) => availabilities[date.toDateString()] === true,
|
|
324
|
+
unavailable: (date) => availabilities[date.toDateString()] === false,
|
|
325
|
+
}}
|
|
326
|
+
disabledDates={
|
|
327
|
+
Object.keys(availabilities)
|
|
328
|
+
.filter(key => !availabilities[key])
|
|
329
|
+
.map(key => new Date(key))
|
|
330
|
+
}
|
|
331
|
+
classNames={{
|
|
332
|
+
day: {
|
|
333
|
+
available: "bg-green-100 text-green-800 hover:bg-green-200",
|
|
334
|
+
unavailable: "bg-red-50 text-red-300 line-through cursor-not-allowed",
|
|
335
|
+
}
|
|
336
|
+
}}
|
|
337
|
+
/>
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
<br />
|
|
341
|
+
|
|
342
|
+
<img src="./docs/images/availability.png" alt="Availability Demo" width="500" />
|
|
343
|
+
|
|
344
|
+
</details>
|
|
345
|
+
|
|
346
|
+
<details>
|
|
347
|
+
<summary><b>Full-Featured / Events Calendar (Google Calendar style)</b></summary>
|
|
348
|
+
Build a full-page events calendar using the `useDates` hook.
|
|
349
|
+
|
|
350
|
+
```tsx
|
|
351
|
+
const { calendars, getBackProps, getForwardProps, getDateProps } = useDates({
|
|
352
|
+
showOutsideDays: true,
|
|
353
|
+
selected: selectedDate,
|
|
354
|
+
onChange: (d) => setSelectedDate(d as Date),
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// Render custom full-grid layout with event badges...
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
<br />
|
|
361
|
+
|
|
362
|
+
<img src="./docs/images/events.png" alt="Events Calendar" width="500" />
|
|
363
|
+
|
|
364
|
+
</details>
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
## Contributors
|
|
369
|
+
|
|
370
|
+
We welcome contributions! Hereâs how you can get started:
|
|
371
|
+
|
|
372
|
+
### Installation
|
|
373
|
+
|
|
374
|
+
1. Clone the repository.
|
|
375
|
+
2. Install dependencies:
|
|
376
|
+
```bash
|
|
377
|
+
pnpm install
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### Development
|
|
381
|
+
|
|
382
|
+
Start the development server with the example app:
|
|
383
|
+
```bash
|
|
384
|
+
pnpm run dev
|
|
385
|
+
```
|
|
386
|
+
This runs `vite` in watch mode for the library and starts the Next.js example app at `http://localhost:3000`.
|
|
387
|
+
|
|
388
|
+
### Testing
|
|
389
|
+
|
|
390
|
+
Run end-to-end tests using Playwright:
|
|
391
|
+
```bash
|
|
392
|
+
pnpm run test:e2e
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Documentation & Examples
|
|
396
|
+
|
|
397
|
+
- To update documentation, edit the `README.md`.
|
|
398
|
+
- To add or modify examples, check the `examples/` directory.
|
|
399
|
+
|
|
400
|
+
### Building
|
|
401
|
+
|
|
402
|
+
Build the package for production:
|
|
403
|
+
```bash
|
|
404
|
+
pnpm run build
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
License: MIT
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
import { DateAdapter } from '../types';
|
|
3
|
+
export declare class DayjsAdapter implements DateAdapter<Dayjs> {
|
|
4
|
+
date(value?: any): Dayjs;
|
|
5
|
+
add(date: Dayjs, amount: number, unit: 'day' | 'month' | 'year'): Dayjs;
|
|
6
|
+
subtract(date: Dayjs, amount: number, unit: 'day' | 'month' | 'year'): Dayjs;
|
|
7
|
+
startOf(date: Dayjs, unit: 'day' | 'month' | 'year'): Dayjs;
|
|
8
|
+
endOf(date: Dayjs, unit: 'day' | 'month' | 'year'): Dayjs;
|
|
9
|
+
isBefore(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean;
|
|
10
|
+
isAfter(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean;
|
|
11
|
+
isSame(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean;
|
|
12
|
+
set(date: Dayjs, unit: 'day' | 'month' | 'year', value: number): Dayjs;
|
|
13
|
+
get(date: Dayjs, unit: 'day' | 'month' | 'year'): number;
|
|
14
|
+
format(date: Dayjs, formatStr: string, locale?: string): string;
|
|
15
|
+
getDaysInMonth(date: Dayjs): number;
|
|
16
|
+
toDate(date: Dayjs): Date;
|
|
17
|
+
diff(date: Dayjs, comparison: Dayjs, unit: 'month' | 'year'): number;
|
|
18
|
+
getMonths(locale?: string): string[];
|
|
19
|
+
getWeekdays(locale?: string): string[];
|
|
20
|
+
}
|
|
21
|
+
export declare const defaultAdapter: DayjsAdapter;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface DayClassNames {
|
|
2
|
+
day?: string;
|
|
3
|
+
selected?: string;
|
|
4
|
+
unselected?: string;
|
|
5
|
+
disabled?: string;
|
|
6
|
+
rangeStart?: string;
|
|
7
|
+
rangeEnd?: string;
|
|
8
|
+
rangeBetween?: string;
|
|
9
|
+
rangeHovering?: string;
|
|
10
|
+
[key: string]: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare const defaultClassNames: {
|
|
13
|
+
root: string;
|
|
14
|
+
header: string;
|
|
15
|
+
calendarsContainer: string;
|
|
16
|
+
calendarContainer: string;
|
|
17
|
+
weekdayGrid: string;
|
|
18
|
+
weekday: string;
|
|
19
|
+
daysGrid: string;
|
|
20
|
+
footer: string;
|
|
21
|
+
navButton: string;
|
|
22
|
+
monthYearContainer: string;
|
|
23
|
+
monthYearLabel: string;
|
|
24
|
+
monthYearButton: string;
|
|
25
|
+
day: {
|
|
26
|
+
day: string;
|
|
27
|
+
selected: string;
|
|
28
|
+
unselected: string;
|
|
29
|
+
disabled: string;
|
|
30
|
+
rangeStart: string;
|
|
31
|
+
rangeEnd: string;
|
|
32
|
+
rangeBetween: string;
|
|
33
|
+
rangeHovering: string;
|
|
34
|
+
};
|
|
35
|
+
monthsGrid: string;
|
|
36
|
+
monthButton: string;
|
|
37
|
+
monthButtonSelected: string;
|
|
38
|
+
monthButtonUnselected: string;
|
|
39
|
+
yearsGrid: string;
|
|
40
|
+
yearButton: string;
|
|
41
|
+
yearButtonSelected: string;
|
|
42
|
+
yearButtonUnselected: string;
|
|
43
|
+
};
|
|
44
|
+
export interface CalendarClassNames {
|
|
45
|
+
root?: string;
|
|
46
|
+
header?: string;
|
|
47
|
+
calendarsContainer?: string;
|
|
48
|
+
calendarContainer?: string;
|
|
49
|
+
weekdayGrid?: string;
|
|
50
|
+
weekday?: string;
|
|
51
|
+
daysGrid?: string;
|
|
52
|
+
footer?: string;
|
|
53
|
+
navButton?: string;
|
|
54
|
+
monthYearContainer?: string;
|
|
55
|
+
monthYearLabel?: string;
|
|
56
|
+
monthYearButton?: string;
|
|
57
|
+
day?: DayClassNames;
|
|
58
|
+
monthsGrid?: string;
|
|
59
|
+
monthButton?: string;
|
|
60
|
+
monthButtonSelected?: string;
|
|
61
|
+
monthButtonUnselected?: string;
|
|
62
|
+
yearsGrid?: string;
|
|
63
|
+
yearButton?: string;
|
|
64
|
+
yearButtonSelected?: string;
|
|
65
|
+
yearButtonUnselected?: string;
|
|
66
|
+
}
|
|
67
|
+
export declare const mergeClassNames: (custom?: CalendarClassNames) => Required<CalendarClassNames>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { UseDatesProps } from '../useDates';
|
|
3
|
+
import { Translations } from '../i18n';
|
|
4
|
+
import { DateObj, CalendarClassNames } from '../types';
|
|
5
|
+
interface CalendarProps extends UseDatesProps {
|
|
6
|
+
classNames?: CalendarClassNames;
|
|
7
|
+
locale?: string;
|
|
8
|
+
translations?: Partial<Translations>;
|
|
9
|
+
header?: React.ReactNode | ((props: any) => React.ReactNode);
|
|
10
|
+
footer?: React.ReactNode;
|
|
11
|
+
renderDayTooltip?: (dateObj: DateObj) => React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare const Calendar: React.FC<CalendarProps>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Calendar, CalendarClassNames } from '../types';
|
|
3
|
+
export interface HeaderProps {
|
|
4
|
+
calendars: Calendar[];
|
|
5
|
+
getBackProps: (args: any) => any;
|
|
6
|
+
getForwardProps: (args: any) => any;
|
|
7
|
+
setView: (view: 'days' | 'months' | 'years') => void;
|
|
8
|
+
monthNames: string[];
|
|
9
|
+
t: {
|
|
10
|
+
back: string;
|
|
11
|
+
forward: string;
|
|
12
|
+
};
|
|
13
|
+
classNames: Required<CalendarClassNames>;
|
|
14
|
+
slideDirection?: 'left' | 'right' | null;
|
|
15
|
+
currentView?: 'days' | 'months' | 'years';
|
|
16
|
+
}
|
|
17
|
+
export declare const ChevronLeftIcon: () => React.JSX.Element;
|
|
18
|
+
export declare const ChevronRightIcon: () => React.JSX.Element;
|
|
19
|
+
export declare const CalendarHeader: React.FC<HeaderProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CalendarClassNames, DateObj } from '../types';
|
|
3
|
+
interface DayProps {
|
|
4
|
+
dateObj: DateObj | null;
|
|
5
|
+
getDateProps: (args: {
|
|
6
|
+
dateObj: DateObj;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}) => any;
|
|
9
|
+
tooltip?: React.ReactNode;
|
|
10
|
+
classNames: Required<CalendarClassNames>;
|
|
11
|
+
}
|
|
12
|
+
export declare const Day: React.FC<DayProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CalendarClassNames } from '../types';
|
|
3
|
+
interface MonthSelectionProps {
|
|
4
|
+
year: number;
|
|
5
|
+
month: number;
|
|
6
|
+
monthNames: string[];
|
|
7
|
+
minDate?: Date | null;
|
|
8
|
+
maxDate?: Date | null;
|
|
9
|
+
onMonthSelect: (month: number) => void;
|
|
10
|
+
classNames: Required<CalendarClassNames>;
|
|
11
|
+
}
|
|
12
|
+
export declare const MonthSelection: React.FC<MonthSelectionProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CalendarClassNames, DateAdapter } from '../types';
|
|
3
|
+
interface YearSelectionProps {
|
|
4
|
+
year: number;
|
|
5
|
+
minDate?: Date | null;
|
|
6
|
+
maxDate?: Date | null;
|
|
7
|
+
adapter: DateAdapter;
|
|
8
|
+
onYearSelect: (year: number) => void;
|
|
9
|
+
classNames: Required<CalendarClassNames>;
|
|
10
|
+
}
|
|
11
|
+
export declare const YearSelection: React.FC<YearSelectionProps>;
|
|
12
|
+
export {};
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DateAdapter } from './types';
|
|
2
|
+
export interface Translations {
|
|
3
|
+
months: string[];
|
|
4
|
+
weekdays: string[];
|
|
5
|
+
back: string;
|
|
6
|
+
forward: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function getDefaults(adapter?: DateAdapter, locale?: string): Translations;
|
|
9
|
+
export declare function getTranslations(adapter?: DateAdapter, locale?: string, custom?: Partial<Translations>): Translations;
|