@corvu-next/calendar 0.1.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/LICENSE +21 -0
- package/dist/index.d.ts +434 -0
- package/dist/index.js +739 -0
- package/dist/index.jsx +825 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-2025 Jasmin Noetzli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import * as _solidjs_web from '@solidjs/web';
|
|
2
|
+
import { ValidComponent, JSX } from '@solidjs/web';
|
|
3
|
+
import { Accessor, Setter } from 'solid-js';
|
|
4
|
+
import { Ref, ElementOf } from '@corvu-next/utils/dom';
|
|
5
|
+
import { DynamicButtonSharedElementProps, DynamicButtonElementProps, DynamicProps } from '@corvu-next/utils/dynamic';
|
|
6
|
+
export { DynamicProps } from '@corvu-next/utils/dynamic';
|
|
7
|
+
|
|
8
|
+
type CalendarContextValue<Mode extends 'single' | 'multiple' | 'range' = 'single' | 'multiple' | 'range'> = Mode extends 'single' ? CalendarContextSingleValue : Mode extends 'multiple' ? CalendarContextMultipleValue : Mode extends 'range' ? CalendarContextRangeValue : CalendarContextSingleValue | CalendarContextMultipleValue | CalendarContextRangeValue;
|
|
9
|
+
type CalendarContextSingleValue = {
|
|
10
|
+
/** The mode of the calendar. */
|
|
11
|
+
mode: Accessor<'single'>;
|
|
12
|
+
/** The value of the calendar. */
|
|
13
|
+
value: Accessor<Date | null>;
|
|
14
|
+
/** Setter to change the value of the calendar. */
|
|
15
|
+
setValue: Setter<Date | null>;
|
|
16
|
+
} & CalendarContextBaseValue;
|
|
17
|
+
type CalendarContextMultipleValue = {
|
|
18
|
+
/** The mode of the calendar. */
|
|
19
|
+
mode: Accessor<'multiple'>;
|
|
20
|
+
/** The value of the calendar. */
|
|
21
|
+
value: Accessor<Date[]>;
|
|
22
|
+
/** Setter to change the value of the calendar. */
|
|
23
|
+
setValue: Setter<Date[]>;
|
|
24
|
+
/** The minimum number of days that have to be selected. */
|
|
25
|
+
min: Accessor<number | null>;
|
|
26
|
+
/** The maximum number of days that can be selected. */
|
|
27
|
+
max: Accessor<number | null>;
|
|
28
|
+
} & CalendarContextBaseValue;
|
|
29
|
+
type CalendarContextRangeValue = {
|
|
30
|
+
/** The mode of the calendar. */
|
|
31
|
+
mode: Accessor<'range'>;
|
|
32
|
+
/** The value of the calendar. */
|
|
33
|
+
value: Accessor<{
|
|
34
|
+
from: Date | null;
|
|
35
|
+
to: Date | null;
|
|
36
|
+
}>;
|
|
37
|
+
/** Setter to change the value of the calendar. */
|
|
38
|
+
setValue: Setter<{
|
|
39
|
+
from: Date | null;
|
|
40
|
+
to: Date | null;
|
|
41
|
+
}>;
|
|
42
|
+
/** Whether to reset the range selection if a disabled day is included in the range. */
|
|
43
|
+
excludeDisabled: Accessor<boolean>;
|
|
44
|
+
} & CalendarContextBaseValue;
|
|
45
|
+
type CalendarContextBaseValue = {
|
|
46
|
+
/** The month to display in the calendar. Is always the first month if multiple months are displayed. */
|
|
47
|
+
month: Accessor<Date>;
|
|
48
|
+
/** Setter to change the month to display in the calendar. Automatically adjusts the focusedDay to be within the visible range. */
|
|
49
|
+
setMonth: Setter<Date>;
|
|
50
|
+
/** The day that is currently focused in the calendar grid. */
|
|
51
|
+
focusedDay: Accessor<Date>;
|
|
52
|
+
/** Setter to change the focused day in the calendar grid. Automatically adjusts the month to ensure the focused day is visible. */
|
|
53
|
+
setFocusedDay: Setter<Date>;
|
|
54
|
+
/** The first day of the week. (0-6, 0 is Sunday) */
|
|
55
|
+
startOfWeek: Accessor<number>;
|
|
56
|
+
/** Whether the value is required. Prevents unselecting the value. */
|
|
57
|
+
required: Accessor<boolean>;
|
|
58
|
+
/** The number of months to display in the calendar. */
|
|
59
|
+
numberOfMonths: Accessor<number>;
|
|
60
|
+
/** Whether to disable outside days (Days falling in the previous or next month). */
|
|
61
|
+
disableOutsideDays: Accessor<boolean>;
|
|
62
|
+
/** Whether to always display 6 weeks in a month. */
|
|
63
|
+
fixedWeeks: Accessor<boolean>;
|
|
64
|
+
/** The text direction of the calendar. */
|
|
65
|
+
textDirection: Accessor<'ltr' | 'rtl'>;
|
|
66
|
+
/** Array of weekdays starting from the first day of the week. */
|
|
67
|
+
weekdays: Accessor<Date[]>;
|
|
68
|
+
/** Array of the currently displayed months. */
|
|
69
|
+
months: Accessor<{
|
|
70
|
+
month: Date;
|
|
71
|
+
weeks: Date[][];
|
|
72
|
+
}[]>;
|
|
73
|
+
/** Function to get the weeks of the current month. Useful if only one month is being rendered. */
|
|
74
|
+
weeks: Accessor<Date[][]>;
|
|
75
|
+
/** Function to navigate the calendar. */
|
|
76
|
+
navigate: (action: `${'prev' | 'next'}-${'month' | 'year'}` | ((date: Date) => Date)) => void;
|
|
77
|
+
/** The ref of the currently focused calendar cell trigger. */
|
|
78
|
+
focusedDayRef: Accessor<HTMLElement | null>;
|
|
79
|
+
/** The `id` attributes of the calendar label elements. Can be undefined if no `Calendar.Label` is present for the given month index. */
|
|
80
|
+
labelIds: Accessor<Accessor<string | undefined>[]>;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
type CalendarCellCorvuProps = {};
|
|
84
|
+
type CalendarCellSharedElementProps<T extends ValidComponent = 'td'> = {};
|
|
85
|
+
type CalendarCellElementProps = CalendarCellSharedElementProps & {
|
|
86
|
+
role: 'presentation';
|
|
87
|
+
'data-corvu-calendar-cell': '' | null;
|
|
88
|
+
};
|
|
89
|
+
type CalendarCellProps<T extends ValidComponent = 'td'> = CalendarCellCorvuProps & Partial<CalendarCellSharedElementProps<T>>;
|
|
90
|
+
|
|
91
|
+
type CalendarCellTriggerCorvuProps = {
|
|
92
|
+
day: Date;
|
|
93
|
+
/**
|
|
94
|
+
* The month that this cell trigger belongs to. Is optional as it's not required if only one month is rendered.
|
|
95
|
+
*/
|
|
96
|
+
month?: Date;
|
|
97
|
+
/**
|
|
98
|
+
* The `id` of the calendar context to use.
|
|
99
|
+
*/
|
|
100
|
+
contextId?: string;
|
|
101
|
+
};
|
|
102
|
+
type CalendarCellTriggerSharedElementProps<T extends ValidComponent = 'button'> = {
|
|
103
|
+
ref: Ref<ElementOf<T>>;
|
|
104
|
+
onClick: JSX.EventHandlerUnion<ElementOf<T>, MouseEvent>;
|
|
105
|
+
onKeyDown: JSX.EventHandlerUnion<ElementOf<T>, KeyboardEvent>;
|
|
106
|
+
disabled: boolean | undefined;
|
|
107
|
+
};
|
|
108
|
+
type CalendarCellTriggerElementProps = CalendarCellTriggerSharedElementProps & {
|
|
109
|
+
role: 'gridcell';
|
|
110
|
+
tabIndex: number;
|
|
111
|
+
'aria-selected': 'true' | 'false' | undefined;
|
|
112
|
+
'aria-disabled': 'true' | undefined;
|
|
113
|
+
'data-selected': '' | undefined;
|
|
114
|
+
'data-disabled': '' | undefined;
|
|
115
|
+
'data-today': '' | undefined;
|
|
116
|
+
'data-range-start': '' | undefined;
|
|
117
|
+
'data-range-end': '' | undefined;
|
|
118
|
+
'data-in-range': '' | undefined;
|
|
119
|
+
'data-corvu-calendar-celltrigger': '' | null;
|
|
120
|
+
};
|
|
121
|
+
type CalendarCellTriggerProps<T extends ValidComponent = 'button'> = CalendarCellTriggerCorvuProps & Partial<CalendarCellTriggerSharedElementProps<T>>;
|
|
122
|
+
|
|
123
|
+
type CalendarHeadCellCorvuProps = {};
|
|
124
|
+
type CalendarHeadCellSharedElementProps<T extends ValidComponent = 'th'> = {
|
|
125
|
+
abbr?: string;
|
|
126
|
+
};
|
|
127
|
+
type CalendarHeadCellElementProps = CalendarHeadCellSharedElementProps & {
|
|
128
|
+
scope: 'col';
|
|
129
|
+
'data-corvu-calendar-headcell': '' | null;
|
|
130
|
+
};
|
|
131
|
+
type CalendarHeadCellProps<T extends ValidComponent = 'th'> = CalendarHeadCellCorvuProps & Partial<CalendarHeadCellSharedElementProps<T>>;
|
|
132
|
+
|
|
133
|
+
type CalendarLabelCorvuProps = {
|
|
134
|
+
/**
|
|
135
|
+
* The index of the calendar table that this label is describing. Is optional as it's not required if only one month is rendered.
|
|
136
|
+
*/
|
|
137
|
+
index?: number;
|
|
138
|
+
/**
|
|
139
|
+
* The `id` of the calendar context to use.
|
|
140
|
+
*/
|
|
141
|
+
contextId?: string;
|
|
142
|
+
};
|
|
143
|
+
type CalendarLabelSharedElementProps<T extends ValidComponent = 'h2'> = {};
|
|
144
|
+
type CalendarLabelElementProps = CalendarLabelSharedElementProps & {
|
|
145
|
+
id: string | undefined;
|
|
146
|
+
'aria-live': 'polite';
|
|
147
|
+
'data-corvu-calendar-label': '' | null;
|
|
148
|
+
};
|
|
149
|
+
type CalendarLabelProps<T extends ValidComponent = 'h2'> = CalendarLabelCorvuProps & Partial<CalendarLabelSharedElementProps<T>>;
|
|
150
|
+
|
|
151
|
+
type CalendarNavCorvuProps = {
|
|
152
|
+
/**
|
|
153
|
+
* The action to perform when pressing this navigation button.
|
|
154
|
+
*/
|
|
155
|
+
action: `${'prev' | 'next'}-${'month' | 'year'}` | ((date: Date) => Date);
|
|
156
|
+
/**
|
|
157
|
+
* The `id` of the calendar context to use.
|
|
158
|
+
*/
|
|
159
|
+
contextId?: string;
|
|
160
|
+
};
|
|
161
|
+
type CalendarNavSharedElementProps<T extends ValidComponent = 'button'> = {
|
|
162
|
+
onClick: JSX.EventHandlerUnion<ElementOf<T>, MouseEvent>;
|
|
163
|
+
} & DynamicButtonSharedElementProps<T>;
|
|
164
|
+
type CalendarNavElementProps = CalendarNavSharedElementProps & DynamicButtonElementProps & {
|
|
165
|
+
'data-corvu-calendar-nav': '' | null;
|
|
166
|
+
};
|
|
167
|
+
type CalendarNavProps<T extends ValidComponent = 'button'> = CalendarNavCorvuProps & Partial<CalendarNavSharedElementProps<T>>;
|
|
168
|
+
|
|
169
|
+
type CalendarRootProps = CalendarRootSingleProps | CalendarRootMultipleProps | CalendarRootRangeProps;
|
|
170
|
+
type CalendarRootSingleProps = {
|
|
171
|
+
/**
|
|
172
|
+
* The mode of the calendar.
|
|
173
|
+
*/
|
|
174
|
+
mode: 'single';
|
|
175
|
+
/**
|
|
176
|
+
* The value of the calendar.
|
|
177
|
+
*/
|
|
178
|
+
value?: Date | null;
|
|
179
|
+
/**
|
|
180
|
+
* Callback fired when the value changes.
|
|
181
|
+
*/
|
|
182
|
+
onValueChange?: (value: Date | null) => void;
|
|
183
|
+
/**
|
|
184
|
+
* The initial value of the calendar.
|
|
185
|
+
* @defaultValue `null`
|
|
186
|
+
*/
|
|
187
|
+
initialValue?: Date | null;
|
|
188
|
+
/** @hidden */
|
|
189
|
+
children: JSX.Element | ((props: CalendarRootChildrenSingleProps) => JSX.Element);
|
|
190
|
+
} & CalendarRootBaseProps;
|
|
191
|
+
type CalendarRootMultipleProps = {
|
|
192
|
+
/**
|
|
193
|
+
* The mode of the calendar.
|
|
194
|
+
*/
|
|
195
|
+
mode: 'multiple';
|
|
196
|
+
/**
|
|
197
|
+
* The value of the calendar.
|
|
198
|
+
*/
|
|
199
|
+
value?: Date[];
|
|
200
|
+
/**
|
|
201
|
+
* Callback fired when the value changes.
|
|
202
|
+
*/
|
|
203
|
+
onValueChange?: (value: Date[]) => void;
|
|
204
|
+
/**
|
|
205
|
+
* The initial value of the calendar.
|
|
206
|
+
* @defaultValue `[]`
|
|
207
|
+
*/
|
|
208
|
+
initialValue?: Date[];
|
|
209
|
+
/**
|
|
210
|
+
* The minimum number of days that have to be selected.
|
|
211
|
+
* @defaultValue `null`
|
|
212
|
+
*/
|
|
213
|
+
min?: number | null;
|
|
214
|
+
/**
|
|
215
|
+
* The maximum number of days that can be selected.
|
|
216
|
+
* @defaultValue `null`
|
|
217
|
+
*/
|
|
218
|
+
max?: number | null;
|
|
219
|
+
/** @hidden */
|
|
220
|
+
children: JSX.Element | ((props: CalendarRootChildrenMultipleProps) => JSX.Element);
|
|
221
|
+
} & CalendarRootBaseProps;
|
|
222
|
+
type CalendarRootRangeProps = {
|
|
223
|
+
/**
|
|
224
|
+
* The mode of the calendar.
|
|
225
|
+
*/
|
|
226
|
+
mode: 'range';
|
|
227
|
+
/**
|
|
228
|
+
* The value of the calendar.
|
|
229
|
+
*/
|
|
230
|
+
value?: {
|
|
231
|
+
from: Date | null;
|
|
232
|
+
to: Date | null;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Callback fired when the value changes.
|
|
236
|
+
*/
|
|
237
|
+
onValueChange?: (value: {
|
|
238
|
+
from: Date | null;
|
|
239
|
+
to: Date | null;
|
|
240
|
+
}) => void;
|
|
241
|
+
/**
|
|
242
|
+
* The initial value of the calendar.
|
|
243
|
+
* @defaultValue `{ from: null, to: null }`
|
|
244
|
+
*/
|
|
245
|
+
initialValue?: {
|
|
246
|
+
from: Date | null;
|
|
247
|
+
to: Date | null;
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Whether to reset the range selection if a disabled day is included in the range.
|
|
251
|
+
* @defaultValue `false`
|
|
252
|
+
*/
|
|
253
|
+
excludeDisabled?: boolean;
|
|
254
|
+
/** @hidden */
|
|
255
|
+
children: JSX.Element | ((props: CalendarRootChildrenRangeProps) => JSX.Element);
|
|
256
|
+
} & CalendarRootBaseProps;
|
|
257
|
+
type CalendarRootBaseProps = {
|
|
258
|
+
/**
|
|
259
|
+
* The month to display in the calendar. Is always the first month if multiple months are displayed.
|
|
260
|
+
*/
|
|
261
|
+
month?: Date;
|
|
262
|
+
/**
|
|
263
|
+
* Callback fired when the month changes.
|
|
264
|
+
*/
|
|
265
|
+
onMonthChange?: (month: Date) => void;
|
|
266
|
+
/**
|
|
267
|
+
* The initial month to display in the calendar.
|
|
268
|
+
* @defaultValue `new Date()`
|
|
269
|
+
*/
|
|
270
|
+
initialMonth?: Date;
|
|
271
|
+
/**
|
|
272
|
+
* The day that is currently focused in the calendar grid.
|
|
273
|
+
*/
|
|
274
|
+
focusedDay?: Date;
|
|
275
|
+
/**
|
|
276
|
+
* Callback fired when the focused day changes.
|
|
277
|
+
*/
|
|
278
|
+
onFocusedDayChange?: (focusedDay: Date) => void;
|
|
279
|
+
/**
|
|
280
|
+
* The initial date that should be focused in the calendar grid.
|
|
281
|
+
* @defaultValue `new Date()`
|
|
282
|
+
*/
|
|
283
|
+
initialFocusedDay?: Date;
|
|
284
|
+
/**
|
|
285
|
+
* The first day of the week. (0-6, 0 is Sunday)
|
|
286
|
+
* @defaultValue `1`
|
|
287
|
+
*/
|
|
288
|
+
startOfWeek?: number;
|
|
289
|
+
/**
|
|
290
|
+
* Whether the value is required. Prevents unselecting the value.
|
|
291
|
+
* @defaultValue `false`
|
|
292
|
+
*/
|
|
293
|
+
required?: boolean;
|
|
294
|
+
/**
|
|
295
|
+
* Callback to determine if any given day is disabled.
|
|
296
|
+
* @defaultValue `() => false`
|
|
297
|
+
*/
|
|
298
|
+
disabled?: (day: Date) => boolean;
|
|
299
|
+
/**
|
|
300
|
+
* The number of months to display in the calendar.
|
|
301
|
+
* @defaultValue `1`
|
|
302
|
+
*/
|
|
303
|
+
numberOfMonths?: number;
|
|
304
|
+
/**
|
|
305
|
+
* Whether to disable outside days (Days falling in the previous or next month).
|
|
306
|
+
* @defaultValue `true`
|
|
307
|
+
*/
|
|
308
|
+
disableOutsideDays?: boolean;
|
|
309
|
+
/**
|
|
310
|
+
* Whether to always display 6 weeks in a month.
|
|
311
|
+
* @defaultValue `false`
|
|
312
|
+
*/
|
|
313
|
+
fixedWeeks?: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* The text direction of the calendar.
|
|
316
|
+
* @defaultValue `ltr`
|
|
317
|
+
*/
|
|
318
|
+
textDirection?: 'ltr' | 'rtl';
|
|
319
|
+
/**
|
|
320
|
+
* The `id` attribute of the calendar label element(s). There can be multiple labels for each month that is being displayed.
|
|
321
|
+
* @defaultValue `createUniqueId()`
|
|
322
|
+
*/
|
|
323
|
+
labelIds?: string[];
|
|
324
|
+
/**
|
|
325
|
+
* The `id` of the calendar context. Useful if you have nested calendars and want to create components that belong to a calendar higher up in the tree.
|
|
326
|
+
*/
|
|
327
|
+
contextId?: string;
|
|
328
|
+
};
|
|
329
|
+
/** Props that are passed to the Root component children callback. */
|
|
330
|
+
type CalendarRootChildrenProps = CalendarRootChildrenSingleProps | CalendarRootChildrenMultipleProps | CalendarRootChildrenRangeProps;
|
|
331
|
+
type CalendarRootChildrenSingleProps = {
|
|
332
|
+
/** The mode of the calendar. */
|
|
333
|
+
mode: 'single';
|
|
334
|
+
/** The value of the calendar. */
|
|
335
|
+
value: Date | null;
|
|
336
|
+
/** Setter to change the value of the calendar. */
|
|
337
|
+
setValue: Setter<Date | null>;
|
|
338
|
+
} & CalendarRootChildrenBaseProps;
|
|
339
|
+
type CalendarRootChildrenMultipleProps = {
|
|
340
|
+
/** The mode of the calendar. */
|
|
341
|
+
mode: 'multiple';
|
|
342
|
+
/** The value of the calendar. */
|
|
343
|
+
value: Date[];
|
|
344
|
+
/** Setter to change the value of the calendar. */
|
|
345
|
+
setValue: Setter<Date[]>;
|
|
346
|
+
/** The minimum number of days that have to be selected. */
|
|
347
|
+
min: number | null;
|
|
348
|
+
/** The maximum number of days that can be selected. */
|
|
349
|
+
max: number | null;
|
|
350
|
+
} & CalendarRootChildrenBaseProps;
|
|
351
|
+
type CalendarRootChildrenRangeProps = {
|
|
352
|
+
/** The mode of the calendar. */
|
|
353
|
+
mode: 'range';
|
|
354
|
+
/** The value of the calendar. */
|
|
355
|
+
value: {
|
|
356
|
+
from: Date | null;
|
|
357
|
+
to: Date | null;
|
|
358
|
+
};
|
|
359
|
+
/** Setter to change the value of the calendar. */
|
|
360
|
+
setValue: Setter<{
|
|
361
|
+
from: Date | null;
|
|
362
|
+
to: Date | null;
|
|
363
|
+
}>;
|
|
364
|
+
/** Whether to reset the range selection if a disabled day is included in the range. */
|
|
365
|
+
excludeDisabled: boolean;
|
|
366
|
+
} & CalendarRootChildrenBaseProps;
|
|
367
|
+
type CalendarRootChildrenBaseProps = {
|
|
368
|
+
/** The month to display in the calendar. Is always the first month if multiple months are displayed. */
|
|
369
|
+
month: Date;
|
|
370
|
+
/** Setter to change the month to display in the calendar. Automatically adjusts the focusedDay to be within the visible range. */
|
|
371
|
+
setMonth: Setter<Date>;
|
|
372
|
+
/** The day that is currently focused in the calendar grid. */
|
|
373
|
+
focusedDay: Date;
|
|
374
|
+
/** Setter to change the focused day in the calendar grid. Automatically adjusts the month to ensure the focused day is visible. */
|
|
375
|
+
setFocusedDay: Setter<Date>;
|
|
376
|
+
/** The first day of the week. (0-6, 0 is Sunday) */
|
|
377
|
+
startOfWeek: number;
|
|
378
|
+
/** Whether the value is required. Prevents unselecting the value. */
|
|
379
|
+
required: boolean;
|
|
380
|
+
/** The number of months to display in the calendar. */
|
|
381
|
+
numberOfMonths: number;
|
|
382
|
+
/** Whether to disable outside days (Days falling in the previous or next month). */
|
|
383
|
+
disableOutsideDays: boolean;
|
|
384
|
+
/** Whether to always display 6 weeks in a month. */
|
|
385
|
+
fixedWeeks: boolean;
|
|
386
|
+
/** The text direction of the calendar. */
|
|
387
|
+
textDirection: 'ltr' | 'rtl';
|
|
388
|
+
/** Array of weekdays starting from the first day of the week. */
|
|
389
|
+
weekdays: Date[];
|
|
390
|
+
/** Array of the currently displayed months. */
|
|
391
|
+
months: {
|
|
392
|
+
month: Date;
|
|
393
|
+
weeks: Date[][];
|
|
394
|
+
}[];
|
|
395
|
+
/** Weeks of the current month. Useful if only one month is being rendered. */
|
|
396
|
+
weeks: Date[][];
|
|
397
|
+
/** Function to navigate the calendar. */
|
|
398
|
+
navigate: (action: `${'prev' | 'next'}-${'month' | 'year'}` | ((date: Date) => Date)) => void;
|
|
399
|
+
/** The ref of the currently focused calendar cell trigger. */
|
|
400
|
+
focusedDayRef: HTMLElement | null;
|
|
401
|
+
/** The `id` attributes of the calendar label elements. Can be undefined if no `Calendar.Label` is present for the given month index. */
|
|
402
|
+
labelIds: (string | undefined)[];
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
type CalendarTableCorvuProps = {
|
|
406
|
+
/**
|
|
407
|
+
* The index of the month that this table is rendering. Is optional as it's not required if only one month is rendered.
|
|
408
|
+
*/
|
|
409
|
+
index?: number;
|
|
410
|
+
/**
|
|
411
|
+
* The `id` of the calendar context to use.
|
|
412
|
+
*/
|
|
413
|
+
contextId?: string;
|
|
414
|
+
};
|
|
415
|
+
type CalendarTableSharedElementProps<T extends ValidComponent = 'table'> = {};
|
|
416
|
+
type CalendarTableElementProps = CalendarTableSharedElementProps & {
|
|
417
|
+
role: 'grid';
|
|
418
|
+
'aria-labelledby': string | undefined;
|
|
419
|
+
'aria-multiselectable': 'true' | undefined;
|
|
420
|
+
'data-corvu-calendar-table': '' | null;
|
|
421
|
+
};
|
|
422
|
+
type CalendarTableProps<T extends ValidComponent = 'table'> = CalendarTableCorvuProps & Partial<CalendarTableSharedElementProps<T>>;
|
|
423
|
+
|
|
424
|
+
declare const Calendar: ((props: CalendarRootProps) => _solidjs_web.JSX.Element) & {
|
|
425
|
+
Label: <T extends _solidjs_web.ValidComponent = "h2">(props: DynamicProps<T, CalendarLabelProps<T>>) => _solidjs_web.JSX.Element;
|
|
426
|
+
Nav: <T extends _solidjs_web.ValidComponent = "button">(props: DynamicProps<T, CalendarNavProps<T>>) => _solidjs_web.JSX.Element;
|
|
427
|
+
Table: <T extends _solidjs_web.ValidComponent = "table">(props: DynamicProps<T, CalendarTableProps<T>>) => _solidjs_web.JSX.Element;
|
|
428
|
+
HeadCell: <T extends _solidjs_web.ValidComponent = "th">(props: DynamicProps<T, CalendarHeadCellProps<T>>) => _solidjs_web.JSX.Element;
|
|
429
|
+
Cell: <T extends _solidjs_web.ValidComponent = "td">(props: DynamicProps<T, CalendarCellProps<T>>) => _solidjs_web.JSX.Element;
|
|
430
|
+
CellTrigger: <T extends _solidjs_web.ValidComponent = "button">(props: DynamicProps<T, CalendarCellTriggerProps<T>>) => _solidjs_web.JSX.Element;
|
|
431
|
+
useContext: <Mode extends "single" | "multiple" | "range" = "single" | "multiple" | "range">(contextId?: string) => CalendarContextValue<Mode>;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
export { type CalendarCellCorvuProps as CellCorvuProps, type CalendarCellElementProps as CellElementProps, type CalendarCellProps as CellProps, type CalendarCellSharedElementProps as CellSharedElementProps, type CalendarCellTriggerCorvuProps as CellTriggerCorvuProps, type CalendarCellTriggerElementProps as CellTriggerElementProps, type CalendarCellTriggerProps as CellTriggerProps, type CalendarCellTriggerSharedElementProps as CellTriggerSharedElementProps, type CalendarContextBaseValue as ContextBaseValue, type CalendarContextMultipleValue as ContextMultipleValue, type CalendarContextRangeValue as ContextRangeValue, type CalendarContextSingleValue as ContextSingleValue, type CalendarContextValue as ContextValue, type CalendarHeadCellCorvuProps as HeadCellCorvuProps, type CalendarHeadCellElementProps as HeadCellElementProps, type CalendarHeadCellProps as HeadCellProps, type CalendarHeadCellSharedElementProps as HeadCellSharedElementProps, type CalendarLabelCorvuProps as LabelCorvuProps, type CalendarLabelElementProps as LabelElementProps, type CalendarLabelProps as LabelProps, type CalendarLabelSharedElementProps as LabelSharedElementProps, type CalendarNavCorvuProps as NavCorvuProps, type CalendarNavElementProps as NavElementProps, type CalendarNavProps as NavProps, type CalendarNavSharedElementProps as NavSharedElementProps, type CalendarRootBaseProps as RootBaseProps, type CalendarRootChildrenBaseProps as RootChildrenBaseProps, type CalendarRootChildrenMultipleProps as RootChildrenMultipleProps, type CalendarRootChildrenProps as RootChildrenProps, type CalendarRootChildrenRangeProps as RootChildrenRangeProps, type CalendarRootChildrenSingleProps as RootChildrenSingleProps, type CalendarRootMultipleProps as RootMultipleProps, type CalendarRootProps as RootProps, type CalendarRootRangeProps as RootRangeProps, type CalendarRootSingleProps as RootSingleProps, type CalendarTableCorvuProps as TableCorvuProps, type CalendarTableElementProps as TableElementProps, type CalendarTableProps as TableProps, type CalendarTableSharedElementProps as TableSharedElementProps, Calendar as default };
|