@super-calendar/solid 2.16.0 → 2.17.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 +46 -2
- package/dist/client/index.d.ts +40 -3
- package/dist/client/index.js +538 -101
- package/dist/server/index.d.ts +40 -3
- package/dist/server/index.js +854 -338
- package/package.json +2 -2
- package/src/Calendar.tsx +73 -2
- package/src/MonthView.tsx +435 -86
- package/src/MultiWeekView.tsx +49 -0
- package/src/index.ts +7 -0
- package/src/touch.ts +70 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/solid",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "Solid 2 calendar and date picker with virtualized views, keyboard navigation, and pointer gestures.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"calendar",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@super-calendar/core": "^2.
|
|
45
|
+
"@super-calendar/core": "^2.17.0",
|
|
46
46
|
"csstype": "^3.1.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
package/src/Calendar.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type JSX } from "@solidjs/web";
|
|
2
2
|
import type { CalendarHandle, CalendarLabels } from "@super-calendar/core/vanilla";
|
|
3
3
|
import {
|
|
4
|
+
buildMultiWeekGrid,
|
|
4
5
|
type BusinessHours,
|
|
5
6
|
type BusinessHoursBand,
|
|
6
7
|
type CalendarEvent,
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
import {
|
|
19
20
|
addDays,
|
|
20
21
|
addMonths,
|
|
22
|
+
addWeeks,
|
|
21
23
|
addYears,
|
|
22
24
|
endOfDay,
|
|
23
25
|
endOfMonth,
|
|
@@ -32,6 +34,7 @@ import {
|
|
|
32
34
|
import { type Component, createMemo, onSettled } from "solid-js";
|
|
33
35
|
import { Agenda, type AgendaSlot, type SolidAgendaEvent } from "./Agenda";
|
|
34
36
|
import { MonthView, type MonthViewSlot, type SolidMonthEvent } from "./MonthView";
|
|
37
|
+
import { MultiWeekView } from "./MultiWeekView";
|
|
35
38
|
import { withDefaults } from "./props";
|
|
36
39
|
import type { SlotStyleProps } from "./slots";
|
|
37
40
|
import { css, type CSSProperties, type DomKeyboardEvent, type ElementRef } from "./styles";
|
|
@@ -83,6 +86,8 @@ export interface CalendarProps<T = unknown>
|
|
|
83
86
|
now?: Date;
|
|
84
87
|
/** Column count for `mode="custom"`. */
|
|
85
88
|
numberOfDays?: number;
|
|
89
|
+
/** Consecutive full week rows for `mode="multiweek"` (default 2). */
|
|
90
|
+
numberOfWeeks?: number;
|
|
86
91
|
/** date-fns locale for titles, headers, and time labels. */
|
|
87
92
|
locale?: Locale;
|
|
88
93
|
/**
|
|
@@ -276,7 +281,12 @@ function expansionRange(
|
|
|
276
281
|
date: Date,
|
|
277
282
|
weekStartsOn: WeekStartsOn,
|
|
278
283
|
numberOfDays: number | undefined,
|
|
284
|
+
numberOfWeeks: number,
|
|
279
285
|
): [Date, Date] {
|
|
286
|
+
if (mode === "multiweek") {
|
|
287
|
+
const { period } = buildMultiWeekGrid(date, { weekStartsOn, numberOfWeeks });
|
|
288
|
+
return [period.start, endOfDay(addDays(period.endExclusive, -1))];
|
|
289
|
+
}
|
|
280
290
|
if (mode === "month") {
|
|
281
291
|
return [
|
|
282
292
|
startOfWeek(startOfMonth(date), {
|
|
@@ -314,7 +324,9 @@ function pageStep(
|
|
|
314
324
|
direction: number,
|
|
315
325
|
weekStartsOn: WeekStartsOn,
|
|
316
326
|
numberOfDays: number | undefined,
|
|
327
|
+
numberOfWeeks: number,
|
|
317
328
|
): Date {
|
|
329
|
+
if (mode === "multiweek") return addWeeks(date, direction * numberOfWeeks);
|
|
318
330
|
if (mode === "year") return addYears(date, direction);
|
|
319
331
|
if (mode === "month") return addMonths(date, direction);
|
|
320
332
|
if (mode === "schedule") return addDays(date, direction * 7);
|
|
@@ -342,6 +354,7 @@ export function Calendar<T = unknown>(
|
|
|
342
354
|
{
|
|
343
355
|
mode: "week",
|
|
344
356
|
weekStartsOn: 0,
|
|
357
|
+
numberOfWeeks: 2,
|
|
345
358
|
} satisfies Partial<
|
|
346
359
|
CalendarProps<T> & {
|
|
347
360
|
ref?: (handle: CalendarHandle) => void;
|
|
@@ -368,6 +381,7 @@ export function Calendar<T = unknown>(
|
|
|
368
381
|
props.date,
|
|
369
382
|
props.weekStartsOn,
|
|
370
383
|
props.numberOfDays,
|
|
384
|
+
props.numberOfWeeks,
|
|
371
385
|
);
|
|
372
386
|
// A display zone shifts each occurrence's wall-clock by up to ~a day, which
|
|
373
387
|
// can move an edge occurrence into a visible column; widen so it's generated.
|
|
@@ -388,11 +402,25 @@ export function Calendar<T = unknown>(
|
|
|
388
402
|
if (!props.onChangeDate) return;
|
|
389
403
|
if (e.key === "PageDown")
|
|
390
404
|
props.onChangeDate(
|
|
391
|
-
pageStep(
|
|
405
|
+
pageStep(
|
|
406
|
+
props.mode,
|
|
407
|
+
props.date,
|
|
408
|
+
1,
|
|
409
|
+
props.weekStartsOn,
|
|
410
|
+
props.numberOfDays,
|
|
411
|
+
props.numberOfWeeks,
|
|
412
|
+
),
|
|
392
413
|
);
|
|
393
414
|
else if (e.key === "PageUp")
|
|
394
415
|
props.onChangeDate(
|
|
395
|
-
pageStep(
|
|
416
|
+
pageStep(
|
|
417
|
+
props.mode,
|
|
418
|
+
props.date,
|
|
419
|
+
-1,
|
|
420
|
+
props.weekStartsOn,
|
|
421
|
+
props.numberOfDays,
|
|
422
|
+
props.numberOfWeeks,
|
|
423
|
+
),
|
|
396
424
|
);
|
|
397
425
|
else return;
|
|
398
426
|
e.preventDefault();
|
|
@@ -494,6 +522,49 @@ export function Calendar<T = unknown>(
|
|
|
494
522
|
eventAccessibilityLabel={props.eventAccessibilityLabel}
|
|
495
523
|
/>
|
|
496
524
|
);
|
|
525
|
+
} else if (mode === "multiweek") {
|
|
526
|
+
return (
|
|
527
|
+
<MultiWeekView<T>
|
|
528
|
+
date={props.date}
|
|
529
|
+
numberOfWeeks={props.numberOfWeeks}
|
|
530
|
+
events={displayEvents()}
|
|
531
|
+
weekStartsOn={props.weekStartsOn}
|
|
532
|
+
hiddenDays={props.hiddenDays}
|
|
533
|
+
weekdayFormat={props.weekdayFormat}
|
|
534
|
+
highlightWeekends={props.highlightWeekends}
|
|
535
|
+
locale={props.locale}
|
|
536
|
+
labels={props.labels}
|
|
537
|
+
theme={props.theme}
|
|
538
|
+
className={props.className}
|
|
539
|
+
style={{ height: props.height, ...props.style }}
|
|
540
|
+
classNames={props.classNames}
|
|
541
|
+
styles={props.styles}
|
|
542
|
+
maxVisibleEventCount={props.maxVisibleEventCount}
|
|
543
|
+
chipHeight={props.chipHeight}
|
|
544
|
+
chipGap={props.chipGap}
|
|
545
|
+
moreLabel={props.moreLabel}
|
|
546
|
+
showTitle={props.showTitle}
|
|
547
|
+
fillCellOnSelection={props.fillCellOnSelection}
|
|
548
|
+
selectedRange={props.selectedRange}
|
|
549
|
+
selectedDates={props.selectedDates}
|
|
550
|
+
minDate={props.minDate}
|
|
551
|
+
maxDate={props.maxDate}
|
|
552
|
+
isDateDisabled={props.isDateDisabled}
|
|
553
|
+
keyboardDayNavigation={props.keyboardDayNavigation}
|
|
554
|
+
onPressDay={props.onPressDay}
|
|
555
|
+
onPressCell={props.onPressCell}
|
|
556
|
+
onCreateEvent={props.onCreateEvent}
|
|
557
|
+
onSelectDrag={props.onSelectDrag}
|
|
558
|
+
onDragEvent={props.onDragEvent}
|
|
559
|
+
onDragStart={props.onDragStart}
|
|
560
|
+
eventStartEditable={props.eventStartEditable}
|
|
561
|
+
eventOverlap={props.eventOverlap}
|
|
562
|
+
onPressEvent={props.onPressEvent}
|
|
563
|
+
onPressMore={props.onPressMore}
|
|
564
|
+
renderEvent={props.renderMonthEvent}
|
|
565
|
+
eventAccessibilityLabel={props.eventAccessibilityLabel}
|
|
566
|
+
/>
|
|
567
|
+
);
|
|
497
568
|
} else {
|
|
498
569
|
return (
|
|
499
570
|
<TimeGrid<T>
|