calendarkit-prov2 2.0.0 → 2.0.2
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 +135 -81
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +64 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React15 from 'react';
|
|
2
|
-
import React15__default, { useState,
|
|
2
|
+
import React15__default, { useState, useEffect, useRef, useCallback, useId, useMemo, useLayoutEffect } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { useDraggable, useSensors, useSensor, PointerSensor, DndContext, DragOverlay, useDroppable } from '@dnd-kit/core';
|
|
5
5
|
import { createSnapModifier, restrictToWindowEdges } from '@dnd-kit/modifiers';
|
|
6
6
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
7
|
-
import {
|
|
7
|
+
import { startOfDay, addDays, endOfDay, startOfWeek, endOfWeek, startOfMonth, endOfMonth, format, differenceInMinutes, subDays, differenceInMilliseconds, eachDayOfInterval, isSameMonth, isToday, isSameDay, addWeeks, addMonths, subWeeks, subMonths, isTomorrow } from 'date-fns';
|
|
8
8
|
import { cva } from 'class-variance-authority';
|
|
9
9
|
import { clsx } from 'clsx';
|
|
10
10
|
import { twMerge } from 'tailwind-merge';
|
|
11
|
-
import { Menu, Plus, ChevronLeft, ChevronRight, Globe, ChevronDown, Sun, Moon, CalendarDays, CalendarRange, Calendar, ListTodo, MoreHorizontal, LayoutGrid, X, Clock, Users, Paperclip, Bell, Edit3, Copy, Trash2, Edit2, MapPin, ExternalLink, AlignLeft, File, Download, BellRing, Check, Repeat, Tag } from 'lucide-react';
|
|
11
|
+
import { Menu, Plus, ChevronLeft, ChevronRight, Globe, ChevronDown, Sun, Moon, CalendarCheck2, CalendarDays, CalendarRange, Calendar, ListTodo, MoreHorizontal, LayoutGrid, X, Clock, Users, Paperclip, Bell, Edit3, Copy, Trash2, Edit2, MapPin, ExternalLink, AlignLeft, File, Download, BellRing, Check, Repeat, Tag } from 'lucide-react';
|
|
12
12
|
import { toZonedTime, fromZonedTime } from 'date-fns-tz';
|
|
13
13
|
import { CSS } from '@dnd-kit/utilities';
|
|
14
14
|
import { RRule } from 'rrule';
|
|
@@ -1494,7 +1494,9 @@ var CalendarHeader = ({
|
|
|
1494
1494
|
onCreateEvent,
|
|
1495
1495
|
customViews,
|
|
1496
1496
|
activeCustomViewId,
|
|
1497
|
-
onCustomViewChange
|
|
1497
|
+
onCustomViewChange,
|
|
1498
|
+
eventCount,
|
|
1499
|
+
hideLanguageSwitcher = false
|
|
1498
1500
|
}) => {
|
|
1499
1501
|
const [isLangOpen, setIsLangOpen] = useState(false);
|
|
1500
1502
|
const [isCustomViewOpen, setIsCustomViewOpen] = useState(false);
|
|
@@ -1586,15 +1588,15 @@ var CalendarHeader = ({
|
|
|
1586
1588
|
className: "h-9 px-5 rounded-xl text-sm font-medium hidden sm:inline-flex border-[0.5px] border-border/60 hover:border-primary/40 hover:bg-primary/5 hover:text-primary transition-all duration-200"
|
|
1587
1589
|
},
|
|
1588
1590
|
translations.today
|
|
1589
|
-
), onCreateEvent && /* @__PURE__ */ React15__default.createElement(
|
|
1591
|
+
), onCreateEvent && /* @__PURE__ */ React15__default.createElement("div", { className: "relative group hidden sm:block" }, /* @__PURE__ */ React15__default.createElement(
|
|
1590
1592
|
Button,
|
|
1591
1593
|
{
|
|
1592
1594
|
onClick: onCreateEvent,
|
|
1593
|
-
|
|
1595
|
+
size: "icon",
|
|
1596
|
+
className: "h-9 w-9 rounded-xl shadow-sm shadow-primary/20 transition-all duration-200"
|
|
1594
1597
|
},
|
|
1595
|
-
/* @__PURE__ */ React15__default.createElement(Plus, { className: "h-4 w-4" })
|
|
1596
|
-
|
|
1597
|
-
), /* @__PURE__ */ React15__default.createElement("div", { className: "flex items-center bg-muted/40 rounded-xl p-0.5" }, /* @__PURE__ */ React15__default.createElement(
|
|
1598
|
+
/* @__PURE__ */ React15__default.createElement(Plus, { className: "h-4 w-4" })
|
|
1599
|
+
), /* @__PURE__ */ React15__default.createElement("div", { className: "pointer-events-none absolute left-1/2 -translate-x-1/2 top-full mt-2 z-50 opacity-0 group-hover:opacity-100 transition-opacity duration-150" }, /* @__PURE__ */ React15__default.createElement("div", { className: "bg-popover text-popover-foreground text-xs font-medium px-2.5 py-1.5 rounded-lg shadow-md border border-border/60 whitespace-nowrap" }, translations.createEvent ?? translations.create), /* @__PURE__ */ React15__default.createElement("div", { className: "absolute -top-1 left-1/2 -translate-x-1/2 w-2 h-2 bg-popover border-l border-t border-border/60 rotate-45" }))), /* @__PURE__ */ React15__default.createElement("div", { className: "flex items-center bg-muted/40 rounded-xl p-0.5" }, /* @__PURE__ */ React15__default.createElement(
|
|
1598
1600
|
Button,
|
|
1599
1601
|
{
|
|
1600
1602
|
variant: "ghost",
|
|
@@ -1612,7 +1614,7 @@ var CalendarHeader = ({
|
|
|
1612
1614
|
className: "rounded-lg h-8 w-8 hover:bg-background/80 transition-all duration-200"
|
|
1613
1615
|
},
|
|
1614
1616
|
/* @__PURE__ */ React15__default.createElement(ChevronRight, { className: "h-4 w-4 text-muted-foreground" })
|
|
1615
|
-
)), /* @__PURE__ */ React15__default.createElement("div", { className: "ml-2 md:ml-4 hidden sm:block" }, /* @__PURE__ */ React15__default.createElement("h2", { className: "text-lg md:text-xl font-semibold text-foreground whitespace-nowrap capitalize tracking-tight" }, format(currentDate, "MMMM yyyy", { locale })))), /* @__PURE__ */ React15__default.createElement("div", { className: "sm:hidden" }, /* @__PURE__ */ React15__default.createElement("h2", { className: "text-lg font-semibold text-foreground whitespace-nowrap capitalize tracking-tight" }, format(currentDate, "MMMM yyyy", { locale })))), /* @__PURE__ */ React15__default.createElement("div", { className: "flex items-center gap-2 md:gap-3 w-full md:w-auto justify-end" }, onLanguageChange && /* @__PURE__ */ React15__default.createElement("div", { className: "relative" }, /* @__PURE__ */ React15__default.createElement(
|
|
1617
|
+
)), /* @__PURE__ */ React15__default.createElement("div", { className: "ml-2 md:ml-4 hidden sm:block" }, /* @__PURE__ */ React15__default.createElement("h2", { className: "text-lg md:text-xl font-semibold text-foreground whitespace-nowrap capitalize tracking-tight" }, format(currentDate, "MMMM yyyy", { locale })))), /* @__PURE__ */ React15__default.createElement("div", { className: "sm:hidden" }, /* @__PURE__ */ React15__default.createElement("h2", { className: "text-lg font-semibold text-foreground whitespace-nowrap capitalize tracking-tight" }, format(currentDate, "MMMM yyyy", { locale })))), /* @__PURE__ */ React15__default.createElement("div", { className: "flex items-center gap-2 md:gap-3 w-full md:w-auto justify-end" }, onLanguageChange && !hideLanguageSwitcher && /* @__PURE__ */ React15__default.createElement("div", { className: "relative" }, /* @__PURE__ */ React15__default.createElement(
|
|
1616
1618
|
"button",
|
|
1617
1619
|
{
|
|
1618
1620
|
ref: langButtonRef,
|
|
@@ -1666,6 +1668,14 @@ var CalendarHeader = ({
|
|
|
1666
1668
|
onClick: onThemeToggle
|
|
1667
1669
|
},
|
|
1668
1670
|
isDarkMode ? /* @__PURE__ */ React15__default.createElement(Sun, { className: "h-4 w-4 text-amber-500" }) : /* @__PURE__ */ React15__default.createElement(Moon, { className: "h-4 w-4 text-muted-foreground" })
|
|
1671
|
+
), typeof eventCount === "number" && !hideViewSwitcher && /* @__PURE__ */ React15__default.createElement(
|
|
1672
|
+
"div",
|
|
1673
|
+
{
|
|
1674
|
+
className: "flex items-center gap-1.5 h-8 px-3 rounded-xl bg-primary/10 text-primary text-xs font-semibold tabular-nums select-none border border-primary/20 shadow-sm shadow-primary/10",
|
|
1675
|
+
title: `${eventCount} event${eventCount !== 1 ? "s" : ""}`
|
|
1676
|
+
},
|
|
1677
|
+
/* @__PURE__ */ React15__default.createElement(CalendarCheck2, { className: "w-3.5 h-3.5 shrink-0" }),
|
|
1678
|
+
/* @__PURE__ */ React15__default.createElement("span", null, eventCount)
|
|
1669
1679
|
), !hideViewSwitcher && /* @__PURE__ */ React15__default.createElement("div", { className: "flex items-center bg-muted/50 backdrop-blur-sm rounded-xl p-1 gap-0.5" }, viewConfig.map(({ key, icon: Icon }) => /* @__PURE__ */ React15__default.createElement(
|
|
1670
1680
|
Button,
|
|
1671
1681
|
{
|
|
@@ -4119,6 +4129,7 @@ var Scheduler = ({
|
|
|
4119
4129
|
onThemeToggle,
|
|
4120
4130
|
translations,
|
|
4121
4131
|
hideViewSwitcher,
|
|
4132
|
+
hideLanguageSwitcher,
|
|
4122
4133
|
initialScrollHour = 8,
|
|
4123
4134
|
reverseTime: reverseTimeProp = false,
|
|
4124
4135
|
language = "tr",
|
|
@@ -4130,7 +4141,21 @@ var Scheduler = ({
|
|
|
4130
4141
|
}) => {
|
|
4131
4142
|
const [activeCustomMenu, setActiveCustomMenu] = useState(null);
|
|
4132
4143
|
const [activeCustomViewId, setActiveCustomViewId] = useState(null);
|
|
4133
|
-
const
|
|
4144
|
+
const REVERSE_TIME_KEY = "calendarkit:reverseTime";
|
|
4145
|
+
const [reverseTime, setReverseTime] = useState(() => {
|
|
4146
|
+
try {
|
|
4147
|
+
const stored = localStorage.getItem(REVERSE_TIME_KEY);
|
|
4148
|
+
return stored !== null ? stored === "true" : reverseTimeProp;
|
|
4149
|
+
} catch {
|
|
4150
|
+
return reverseTimeProp;
|
|
4151
|
+
}
|
|
4152
|
+
});
|
|
4153
|
+
useEffect(() => {
|
|
4154
|
+
try {
|
|
4155
|
+
localStorage.setItem(REVERSE_TIME_KEY, String(reverseTime));
|
|
4156
|
+
} catch {
|
|
4157
|
+
}
|
|
4158
|
+
}, [reverseTime]);
|
|
4134
4159
|
const [activeDragEvent, setActiveDragEvent] = useState(null);
|
|
4135
4160
|
const schedulerRef = useRef(null);
|
|
4136
4161
|
const [fabCssVars, setFabCssVars] = useState({});
|
|
@@ -4269,6 +4294,34 @@ var Scheduler = ({
|
|
|
4269
4294
|
return activeCalendarIds.includes(e.calendarId);
|
|
4270
4295
|
});
|
|
4271
4296
|
}, [expandedEvents, calendars]);
|
|
4297
|
+
const viewEventCount = useMemo(() => {
|
|
4298
|
+
let rangeStart;
|
|
4299
|
+
let rangeEnd;
|
|
4300
|
+
switch (view) {
|
|
4301
|
+
case "month":
|
|
4302
|
+
rangeStart = startOfMonth(currentDate);
|
|
4303
|
+
rangeEnd = endOfMonth(currentDate);
|
|
4304
|
+
break;
|
|
4305
|
+
case "week":
|
|
4306
|
+
rangeStart = startOfWeek(currentDate, { weekStartsOn: 1 });
|
|
4307
|
+
rangeEnd = endOfWeek(currentDate, { weekStartsOn: 1 });
|
|
4308
|
+
break;
|
|
4309
|
+
case "day":
|
|
4310
|
+
case "resource":
|
|
4311
|
+
rangeStart = startOfDay(currentDate);
|
|
4312
|
+
rangeEnd = endOfDay(currentDate);
|
|
4313
|
+
break;
|
|
4314
|
+
case "agenda":
|
|
4315
|
+
rangeStart = startOfDay(currentDate);
|
|
4316
|
+
rangeEnd = addDays(rangeStart, 30);
|
|
4317
|
+
break;
|
|
4318
|
+
default:
|
|
4319
|
+
return filteredEvents.length;
|
|
4320
|
+
}
|
|
4321
|
+
return filteredEvents.filter(
|
|
4322
|
+
(e) => e.start >= rangeStart && e.start <= rangeEnd
|
|
4323
|
+
).length;
|
|
4324
|
+
}, [filteredEvents, view, currentDate]);
|
|
4272
4325
|
return /* @__PURE__ */ React15__default.createElement(React15__default.Fragment, null, /* @__PURE__ */ React15__default.createElement(
|
|
4273
4326
|
DndContext,
|
|
4274
4327
|
{
|
|
@@ -4323,7 +4376,9 @@ var Scheduler = ({
|
|
|
4323
4376
|
onCustomViewChange: (id2) => {
|
|
4324
4377
|
setActiveCustomViewId(id2);
|
|
4325
4378
|
setActiveCustomMenu(null);
|
|
4326
|
-
}
|
|
4379
|
+
},
|
|
4380
|
+
eventCount: viewEventCount,
|
|
4381
|
+
hideLanguageSwitcher
|
|
4327
4382
|
}
|
|
4328
4383
|
),
|
|
4329
4384
|
/* @__PURE__ */ React15__default.createElement("div", { className: "flex flex-1 overflow-hidden" }, /* @__PURE__ */ React15__default.createElement(
|