@super-calendar/dom 2.4.0 → 2.6.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/dist/index.d.mts +62 -6
- package/dist/index.d.ts +62 -6
- package/dist/index.js +481 -144
- package/dist/index.mjs +483 -147
- package/package.json +2 -2
- package/src/Calendar.tsx +38 -8
- package/src/ResourceTimeline.tsx +192 -3
- package/src/YearView.tsx +283 -0
- package/src/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -235,6 +235,183 @@ function Agenda({ events, locale, ampm = false, activeDate, theme: themeOverride
|
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
//#endregion
|
|
238
|
+
//#region src/YearView.tsx
|
|
239
|
+
/**
|
|
240
|
+
* A year at a glance: the twelve months as compact mini grids, with today
|
|
241
|
+
* highlighted and a dot under days that hold events. It's the view `Calendar`
|
|
242
|
+
* renders for `mode="year"`.
|
|
243
|
+
*/
|
|
244
|
+
function YearView({ date, events, weekStartsOn = 0, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, theme: themeOverrides, className, style, classNames, styles }) {
|
|
245
|
+
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
246
|
+
const slot = createSlots({
|
|
247
|
+
classNames,
|
|
248
|
+
styles
|
|
249
|
+
});
|
|
250
|
+
const months = (0, react.useMemo)(() => (0, _super_calendar_core.getYearMonths)(date), [date]);
|
|
251
|
+
const weekdayLabels = (0, react.useMemo)(() => (0, _super_calendar_core.getWeekDays)(date, weekStartsOn).map((d) => (0, date_fns.format)(d, (0, _super_calendar_core.weekdayFormatToken)("narrow"), { locale })), [
|
|
252
|
+
date,
|
|
253
|
+
weekStartsOn,
|
|
254
|
+
locale
|
|
255
|
+
]);
|
|
256
|
+
const eventDays = (0, react.useMemo)(() => new Set(events && events.length > 0 ? (0, _super_calendar_core.groupEventsByDay)(events).keys() : []), [events]);
|
|
257
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
258
|
+
className,
|
|
259
|
+
style: {
|
|
260
|
+
fontFamily: theme.fontFamily,
|
|
261
|
+
color: theme.text,
|
|
262
|
+
overflowY: "auto",
|
|
263
|
+
...style
|
|
264
|
+
},
|
|
265
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
266
|
+
...slot("grid", { base: {
|
|
267
|
+
display: "grid",
|
|
268
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(${minMonthWidth}px, 1fr))`
|
|
269
|
+
} }),
|
|
270
|
+
children: months.map((month) => {
|
|
271
|
+
const weeks = (0, _super_calendar_core.buildMonthWeeks)(month, weekStartsOn);
|
|
272
|
+
const monthLabel = (0, date_fns.format)(month, "MMMM yyyy", { locale });
|
|
273
|
+
const titleContent = (0, date_fns.format)(month, "MMMM", { locale });
|
|
274
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
275
|
+
...slot("month", { base: { padding: 8 } }),
|
|
276
|
+
children: [
|
|
277
|
+
onPressMonth ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
278
|
+
type: "button",
|
|
279
|
+
onClick: () => onPressMonth(month),
|
|
280
|
+
"aria-label": monthLabel,
|
|
281
|
+
...slot("monthTitle", {
|
|
282
|
+
base: {
|
|
283
|
+
display: "block",
|
|
284
|
+
border: "none",
|
|
285
|
+
background: "transparent",
|
|
286
|
+
padding: "0 0 4px",
|
|
287
|
+
cursor: "pointer",
|
|
288
|
+
font: "inherit",
|
|
289
|
+
textAlign: "left"
|
|
290
|
+
},
|
|
291
|
+
themed: {
|
|
292
|
+
fontSize: 13,
|
|
293
|
+
fontWeight: 700,
|
|
294
|
+
color: theme.todayBackground
|
|
295
|
+
}
|
|
296
|
+
}),
|
|
297
|
+
children: titleContent
|
|
298
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
299
|
+
role: "heading",
|
|
300
|
+
"aria-level": 3,
|
|
301
|
+
"aria-label": monthLabel,
|
|
302
|
+
...slot("monthTitle", {
|
|
303
|
+
base: { paddingBottom: 4 },
|
|
304
|
+
themed: {
|
|
305
|
+
fontSize: 13,
|
|
306
|
+
fontWeight: 700,
|
|
307
|
+
color: theme.todayBackground
|
|
308
|
+
}
|
|
309
|
+
}),
|
|
310
|
+
children: titleContent
|
|
311
|
+
}),
|
|
312
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
313
|
+
...slot("weekdays", { base: {
|
|
314
|
+
display: "grid",
|
|
315
|
+
gridTemplateColumns: "repeat(7, 1fr)"
|
|
316
|
+
} }),
|
|
317
|
+
children: weekdayLabels.map((label, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
318
|
+
"aria-hidden": true,
|
|
319
|
+
...slot("weekday", {
|
|
320
|
+
base: { textAlign: "center" },
|
|
321
|
+
themed: {
|
|
322
|
+
fontSize: 9,
|
|
323
|
+
fontWeight: 600,
|
|
324
|
+
color: theme.textMuted
|
|
325
|
+
}
|
|
326
|
+
}),
|
|
327
|
+
children: label
|
|
328
|
+
}, i))
|
|
329
|
+
}),
|
|
330
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
331
|
+
role: "grid",
|
|
332
|
+
"aria-label": monthLabel,
|
|
333
|
+
children: weeks.map((week) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
334
|
+
role: "row",
|
|
335
|
+
...slot("week", { base: {
|
|
336
|
+
display: "grid",
|
|
337
|
+
gridTemplateColumns: "repeat(7, 1fr)"
|
|
338
|
+
} }),
|
|
339
|
+
children: week.map((day) => {
|
|
340
|
+
if (day.getMonth() !== month.getMonth()) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
341
|
+
role: "gridcell",
|
|
342
|
+
"aria-hidden": true,
|
|
343
|
+
style: { aspectRatio: "1" }
|
|
344
|
+
}, day.toISOString());
|
|
345
|
+
const isHighlighted = activeDate ? (0, _super_calendar_core.isSameCalendarDay)(day, activeDate) : (0, _super_calendar_core.getIsToday)(day);
|
|
346
|
+
const hasEvents = eventDays.has((0, date_fns.startOfDay)(day).toISOString());
|
|
347
|
+
const label = `${(0, date_fns.format)(day, "EEEE, d LLLL yyyy", { locale })}${(0, _super_calendar_core.getIsToday)(day) ? ", today" : ""}${hasEvents ? ", has events" : ""}`;
|
|
348
|
+
const daySlot = slot("day", {
|
|
349
|
+
base: {
|
|
350
|
+
position: "relative",
|
|
351
|
+
aspectRatio: "1",
|
|
352
|
+
display: "flex",
|
|
353
|
+
alignItems: "center",
|
|
354
|
+
justifyContent: "center",
|
|
355
|
+
padding: 0,
|
|
356
|
+
border: "none",
|
|
357
|
+
background: "transparent",
|
|
358
|
+
font: "inherit",
|
|
359
|
+
cursor: onPressDay ? "pointer" : "default",
|
|
360
|
+
boxSizing: "border-box"
|
|
361
|
+
},
|
|
362
|
+
themed: {
|
|
363
|
+
fontSize: 11,
|
|
364
|
+
borderRadius: "50%",
|
|
365
|
+
...isHighlighted ? {
|
|
366
|
+
background: theme.todayBackground,
|
|
367
|
+
color: theme.todayText
|
|
368
|
+
} : { color: theme.text }
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
const states = dataState({
|
|
372
|
+
"data-today": (0, _super_calendar_core.getIsToday)(day),
|
|
373
|
+
"data-events": hasEvents
|
|
374
|
+
});
|
|
375
|
+
const dot = hasEvents ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
376
|
+
"aria-hidden": true,
|
|
377
|
+
...slot("eventDot", {
|
|
378
|
+
base: {
|
|
379
|
+
position: "absolute",
|
|
380
|
+
bottom: 1,
|
|
381
|
+
left: "50%",
|
|
382
|
+
marginLeft: -1.5,
|
|
383
|
+
width: 3,
|
|
384
|
+
height: 3,
|
|
385
|
+
borderRadius: 2
|
|
386
|
+
},
|
|
387
|
+
themed: { background: isHighlighted ? theme.todayText : theme.todayBackground }
|
|
388
|
+
})
|
|
389
|
+
}) : null;
|
|
390
|
+
return onPressDay ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
391
|
+
type: "button",
|
|
392
|
+
role: "gridcell",
|
|
393
|
+
onClick: () => onPressDay(day),
|
|
394
|
+
"aria-label": label,
|
|
395
|
+
...states,
|
|
396
|
+
...daySlot,
|
|
397
|
+
children: [day.getDate(), dot]
|
|
398
|
+
}, day.toISOString()) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
399
|
+
role: "gridcell",
|
|
400
|
+
"aria-label": label,
|
|
401
|
+
...states,
|
|
402
|
+
...daySlot,
|
|
403
|
+
children: [day.getDate(), dot]
|
|
404
|
+
}, day.toISOString());
|
|
405
|
+
})
|
|
406
|
+
}, week[0].toISOString()))
|
|
407
|
+
})
|
|
408
|
+
]
|
|
409
|
+
}, month.toISOString());
|
|
410
|
+
})
|
|
411
|
+
})
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
//#endregion
|
|
238
415
|
//#region src/MonthView.tsx
|
|
239
416
|
const DATE_ROW = 24;
|
|
240
417
|
const CHIP_HEIGHT = 18;
|
|
@@ -1533,11 +1710,13 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1533
1710
|
const EMPTY_EVENTS = [];
|
|
1534
1711
|
function expansionRange(mode, date, weekStartsOn, numberOfDays) {
|
|
1535
1712
|
if (mode === "month") return [(0, date_fns.startOfWeek)((0, date_fns.startOfMonth)(date), { weekStartsOn }), (0, date_fns.endOfWeek)((0, date_fns.endOfMonth)(date), { weekStartsOn })];
|
|
1713
|
+
if (mode === "year") return [(0, date_fns.startOfWeek)((0, date_fns.startOfYear)(date), { weekStartsOn }), (0, date_fns.endOfWeek)((0, date_fns.endOfYear)(date), { weekStartsOn })];
|
|
1536
1714
|
if (mode === "schedule") return [(0, date_fns.startOfDay)(date), (0, date_fns.endOfDay)((0, date_fns.addMonths)(date, 3))];
|
|
1537
1715
|
const days = (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays ?? 1);
|
|
1538
1716
|
return [(0, date_fns.startOfDay)(days[0]), (0, date_fns.endOfDay)(days[days.length - 1])];
|
|
1539
1717
|
}
|
|
1540
1718
|
function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
1719
|
+
if (mode === "year") return (0, date_fns.addYears)(date, direction);
|
|
1541
1720
|
if (mode === "month") return (0, date_fns.addMonths)(date, direction);
|
|
1542
1721
|
if (mode === "schedule") return (0, date_fns.addDays)(date, direction * 7);
|
|
1543
1722
|
return (0, date_fns.addDays)(date, direction * (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays ?? 1).length);
|
|
@@ -1553,7 +1732,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
1553
1732
|
* <Calendar mode="week" date={new Date()} events={events} />
|
|
1554
1733
|
* ```
|
|
1555
1734
|
*/
|
|
1556
|
-
function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, showNowIndicator, showAllDayEventCell, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
1735
|
+
function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, showNowIndicator, showAllDayEventCell, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
1557
1736
|
const displayEvents = (0, react.useMemo)(() => {
|
|
1558
1737
|
let out = events ?? EMPTY_EVENTS;
|
|
1559
1738
|
if (out.some((e) => e.recurrence)) {
|
|
@@ -1582,7 +1761,23 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
1582
1761
|
e.preventDefault();
|
|
1583
1762
|
};
|
|
1584
1763
|
let view;
|
|
1585
|
-
if (mode === "
|
|
1764
|
+
if (mode === "year") view = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(YearView, {
|
|
1765
|
+
date,
|
|
1766
|
+
events: displayEvents,
|
|
1767
|
+
weekStartsOn,
|
|
1768
|
+
locale,
|
|
1769
|
+
theme,
|
|
1770
|
+
className,
|
|
1771
|
+
style: height != null ? {
|
|
1772
|
+
height,
|
|
1773
|
+
...style
|
|
1774
|
+
} : style,
|
|
1775
|
+
classNames,
|
|
1776
|
+
styles,
|
|
1777
|
+
onPressDay,
|
|
1778
|
+
onPressMonth
|
|
1779
|
+
});
|
|
1780
|
+
else if (mode === "schedule") view = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Agenda, {
|
|
1586
1781
|
events: displayEvents,
|
|
1587
1782
|
locale,
|
|
1588
1783
|
ampm,
|
|
@@ -2092,7 +2287,7 @@ function DefaultBar({ event, height, boxProps, theme }) {
|
|
|
2092
2287
|
* />
|
|
2093
2288
|
* ```
|
|
2094
2289
|
*/
|
|
2095
|
-
function ResourceTimeline({ date, orientation = "horizontal", resources, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, theme: themeOverrides, renderEvent, onPressEvent, onDragEvent, dragStepMinutes = 15, className, style, classNames, styles }) {
|
|
2290
|
+
function ResourceTimeline({ date, orientation = "horizontal", resources, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, theme: themeOverrides, renderEvent, onPressEvent, onDragEvent, onPressCell, onCreateEvent, businessHours, dragStepMinutes = 15, className, style, classNames, styles }) {
|
|
2096
2291
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
2097
2292
|
const slot = createSlots({
|
|
2098
2293
|
classNames,
|
|
@@ -2171,6 +2366,69 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2171
2366
|
applyDrag(null);
|
|
2172
2367
|
origin.current = null;
|
|
2173
2368
|
};
|
|
2369
|
+
const [createBox, setCreateBox] = (0, react.useState)(null);
|
|
2370
|
+
const createOrigin = (0, react.useRef)(null);
|
|
2371
|
+
const cellEnabled = !!onPressCell || !!onCreateEvent;
|
|
2372
|
+
const pxAlongAxis = (el, e) => {
|
|
2373
|
+
const rect = el.getBoundingClientRect();
|
|
2374
|
+
return vertical ? e.clientY - rect.top : e.clientX - rect.left;
|
|
2375
|
+
};
|
|
2376
|
+
const beginCreate = (e, resource) => {
|
|
2377
|
+
if (!cellEnabled || e.pointerType === "touch") return;
|
|
2378
|
+
if (e.target !== e.currentTarget || e.button > 0) return;
|
|
2379
|
+
const el = e.currentTarget;
|
|
2380
|
+
const startPx = pxAlongAxis(el, e);
|
|
2381
|
+
try {
|
|
2382
|
+
el.setPointerCapture?.(e.pointerId);
|
|
2383
|
+
} catch {}
|
|
2384
|
+
createOrigin.current = {
|
|
2385
|
+
el,
|
|
2386
|
+
resource,
|
|
2387
|
+
startPx
|
|
2388
|
+
};
|
|
2389
|
+
if (onCreateEvent) setCreateBox({
|
|
2390
|
+
resourceKey: resource.id,
|
|
2391
|
+
startPx,
|
|
2392
|
+
curPx: startPx
|
|
2393
|
+
});
|
|
2394
|
+
};
|
|
2395
|
+
const moveCreate = (e) => {
|
|
2396
|
+
const o = createOrigin.current;
|
|
2397
|
+
if (!o || !onCreateEvent) return;
|
|
2398
|
+
setCreateBox({
|
|
2399
|
+
resourceKey: o.resource.id,
|
|
2400
|
+
startPx: o.startPx,
|
|
2401
|
+
curPx: pxAlongAxis(o.el, e)
|
|
2402
|
+
});
|
|
2403
|
+
};
|
|
2404
|
+
const endCreate = (e) => {
|
|
2405
|
+
const o = createOrigin.current;
|
|
2406
|
+
if (!o) return;
|
|
2407
|
+
try {
|
|
2408
|
+
o.el.releasePointerCapture?.(e.pointerId);
|
|
2409
|
+
} catch {}
|
|
2410
|
+
const endPx = pxAlongAxis(o.el, e);
|
|
2411
|
+
if (Math.abs(endPx - o.startPx) > 4 && onCreateEvent) {
|
|
2412
|
+
const range = (0, _super_calendar_core.cellRangeFromDrag)(date, o.startPx, endPx, hourSize, startHour, dragStepMinutes);
|
|
2413
|
+
if (range) onCreateEvent(range.start, range.end, o.resource);
|
|
2414
|
+
} else if (onPressCell) {
|
|
2415
|
+
const at = (0, _super_calendar_core.cellRangeFromDrag)(date, o.startPx, o.startPx, hourSize, startHour, dragStepMinutes);
|
|
2416
|
+
if (at) onPressCell(at.start, o.resource);
|
|
2417
|
+
}
|
|
2418
|
+
createOrigin.current = null;
|
|
2419
|
+
setCreateBox(null);
|
|
2420
|
+
};
|
|
2421
|
+
const cancelCreate = () => {
|
|
2422
|
+
createOrigin.current = null;
|
|
2423
|
+
setCreateBox(null);
|
|
2424
|
+
};
|
|
2425
|
+
const trackInteractionProps = (resource) => cellEnabled ? {
|
|
2426
|
+
onPointerDown: (e) => beginCreate(e, resource),
|
|
2427
|
+
onPointerMove: moveCreate,
|
|
2428
|
+
onPointerUp: endCreate,
|
|
2429
|
+
onPointerCancel: cancelCreate
|
|
2430
|
+
} : null;
|
|
2431
|
+
const bandsFor = (resource) => businessHours ? (0, _super_calendar_core.closedHourBands)(date, (d) => businessHours(d, resource), startHour, endHour) : [];
|
|
2174
2432
|
const hours = (0, react.useMemo)(() => Array.from({ length: Math.max(0, endHour - startHour) }, (_, i) => startHour + i), [startHour, endHour]);
|
|
2175
2433
|
const trackWidth = (endHour - startHour) * hourWidth;
|
|
2176
2434
|
const byResource = (0, react.useMemo)(() => {
|
|
@@ -2267,85 +2525,124 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2267
2525
|
themed: { borderLeft: `1px solid ${theme.gridLine}` }
|
|
2268
2526
|
}),
|
|
2269
2527
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2528
|
+
...trackInteractionProps(resource),
|
|
2270
2529
|
...slot("track", { base: {
|
|
2271
2530
|
position: "relative",
|
|
2272
2531
|
height: trackHeight
|
|
2273
2532
|
} }),
|
|
2274
|
-
children: [
|
|
2275
|
-
"
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
inset: 0,
|
|
2280
|
-
pointerEvents: "none"
|
|
2281
|
-
},
|
|
2282
|
-
themed: { backgroundImage: vGridLines }
|
|
2283
|
-
})
|
|
2284
|
-
}), positioned.map((pe, idx) => {
|
|
2285
|
-
const key = `${resource.id}:${idx}`;
|
|
2286
|
-
const active = drag?.key === key ? drag : null;
|
|
2287
|
-
const startH = active ? active.startHours : pe.startHours;
|
|
2288
|
-
const durH = active ? active.durationHours : pe.durationHours;
|
|
2289
|
-
const top = clamp(startH - startHour, 0, endHour - startHour) * hourHeight;
|
|
2290
|
-
const bottom = clamp(startH + durH - startHour, 0, endHour - startHour) * hourHeight;
|
|
2291
|
-
const height = Math.max(bottom - top, 2);
|
|
2292
|
-
const lanePct = 100 / pe.columns;
|
|
2293
|
-
const onPress = () => onPressEvent?.(pe.event);
|
|
2294
|
-
const args = {
|
|
2295
|
-
event: pe.event,
|
|
2296
|
-
width: 0,
|
|
2297
|
-
height,
|
|
2298
|
-
onPress
|
|
2299
|
-
};
|
|
2300
|
-
const draggable = !!onDragEvent;
|
|
2301
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2302
|
-
type: "button",
|
|
2303
|
-
onClick: draggable ? void 0 : onPress,
|
|
2304
|
-
"aria-label": pe.event.title,
|
|
2305
|
-
...dataState({ "data-dragging": !!active }),
|
|
2306
|
-
onPointerDown: draggable ? (e) => beginDrag(e, key, "move", pe.startHours, pe.durationHours) : void 0,
|
|
2307
|
-
onPointerMove: draggable ? moveDrag : void 0,
|
|
2308
|
-
onPointerUp: draggable ? (e) => endDrag(e, pe.event, onPress) : void 0,
|
|
2309
|
-
onPointerCancel: draggable ? cancelDrag : void 0,
|
|
2310
|
-
...slot("event", { base: {
|
|
2311
|
-
position: "absolute",
|
|
2312
|
-
top,
|
|
2313
|
-
height,
|
|
2314
|
-
left: `${pe.column * lanePct}%`,
|
|
2315
|
-
width: `${lanePct}%`,
|
|
2316
|
-
padding: 1,
|
|
2317
|
-
border: "none",
|
|
2318
|
-
background: "transparent",
|
|
2319
|
-
cursor: draggable ? "grab" : "pointer",
|
|
2320
|
-
touchAction: draggable ? "none" : "auto",
|
|
2321
|
-
font: "inherit",
|
|
2322
|
-
textAlign: "left",
|
|
2323
|
-
boxSizing: "border-box",
|
|
2324
|
-
zIndex: active ? 3 : 1,
|
|
2325
|
-
opacity: active ? .85 : 1
|
|
2326
|
-
} }),
|
|
2327
|
-
children: [Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...args }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultBar, {
|
|
2328
|
-
...args,
|
|
2329
|
-
theme,
|
|
2330
|
-
boxProps: slot("eventBox")
|
|
2331
|
-
}), draggable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2332
|
-
"aria-hidden": true,
|
|
2333
|
-
onPointerDown: (e) => {
|
|
2334
|
-
e.stopPropagation();
|
|
2335
|
-
beginDrag(e, key, "resize", pe.startHours, pe.durationHours);
|
|
2336
|
-
},
|
|
2337
|
-
style: {
|
|
2533
|
+
children: [
|
|
2534
|
+
bandsFor(resource).map((b) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2535
|
+
"aria-hidden": true,
|
|
2536
|
+
...slot("businessHours", {
|
|
2537
|
+
base: {
|
|
2338
2538
|
position: "absolute",
|
|
2339
2539
|
left: 0,
|
|
2340
2540
|
right: 0,
|
|
2341
|
-
|
|
2342
|
-
height:
|
|
2343
|
-
|
|
2344
|
-
|
|
2541
|
+
top: (b.start - startHour) * hourHeight,
|
|
2542
|
+
height: (b.end - b.start) * hourHeight,
|
|
2543
|
+
pointerEvents: "none",
|
|
2544
|
+
zIndex: 0
|
|
2545
|
+
},
|
|
2546
|
+
themed: { background: theme.outsideHoursBackground }
|
|
2547
|
+
})
|
|
2548
|
+
}, b.start)),
|
|
2549
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2550
|
+
"aria-hidden": true,
|
|
2551
|
+
...slot("gridLines", {
|
|
2552
|
+
base: {
|
|
2553
|
+
position: "absolute",
|
|
2554
|
+
inset: 0,
|
|
2555
|
+
pointerEvents: "none"
|
|
2556
|
+
},
|
|
2557
|
+
themed: { backgroundImage: vGridLines }
|
|
2558
|
+
})
|
|
2559
|
+
}),
|
|
2560
|
+
positioned.map((pe, idx) => {
|
|
2561
|
+
const key = `${resource.id}:${idx}`;
|
|
2562
|
+
const active = drag?.key === key ? drag : null;
|
|
2563
|
+
const startH = active ? active.startHours : pe.startHours;
|
|
2564
|
+
const durH = active ? active.durationHours : pe.durationHours;
|
|
2565
|
+
const top = clamp(startH - startHour, 0, endHour - startHour) * hourHeight;
|
|
2566
|
+
const bottom = clamp(startH + durH - startHour, 0, endHour - startHour) * hourHeight;
|
|
2567
|
+
const height = Math.max(bottom - top, 2);
|
|
2568
|
+
const lanePct = 100 / pe.columns;
|
|
2569
|
+
const onPress = () => onPressEvent?.(pe.event);
|
|
2570
|
+
const args = {
|
|
2571
|
+
event: pe.event,
|
|
2572
|
+
width: 0,
|
|
2573
|
+
height,
|
|
2574
|
+
onPress
|
|
2575
|
+
};
|
|
2576
|
+
const draggable = !!onDragEvent;
|
|
2577
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2578
|
+
type: "button",
|
|
2579
|
+
onClick: draggable ? void 0 : onPress,
|
|
2580
|
+
"aria-label": pe.event.title,
|
|
2581
|
+
...dataState({ "data-dragging": !!active }),
|
|
2582
|
+
onPointerDown: draggable ? (e) => beginDrag(e, key, "move", pe.startHours, pe.durationHours) : void 0,
|
|
2583
|
+
onPointerMove: draggable ? moveDrag : void 0,
|
|
2584
|
+
onPointerUp: draggable ? (e) => endDrag(e, pe.event, onPress) : void 0,
|
|
2585
|
+
onPointerCancel: draggable ? cancelDrag : void 0,
|
|
2586
|
+
...slot("event", { base: {
|
|
2587
|
+
position: "absolute",
|
|
2588
|
+
top,
|
|
2589
|
+
height,
|
|
2590
|
+
left: `${pe.column * lanePct}%`,
|
|
2591
|
+
width: `${lanePct}%`,
|
|
2592
|
+
padding: 1,
|
|
2593
|
+
border: "none",
|
|
2594
|
+
background: "transparent",
|
|
2595
|
+
cursor: draggable ? "grab" : "pointer",
|
|
2596
|
+
touchAction: draggable ? "none" : "auto",
|
|
2597
|
+
font: "inherit",
|
|
2598
|
+
textAlign: "left",
|
|
2599
|
+
boxSizing: "border-box",
|
|
2600
|
+
zIndex: active ? 3 : 1,
|
|
2601
|
+
opacity: active ? .85 : 1
|
|
2602
|
+
} }),
|
|
2603
|
+
children: [Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...args }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultBar, {
|
|
2604
|
+
...args,
|
|
2605
|
+
theme,
|
|
2606
|
+
boxProps: slot("eventBox")
|
|
2607
|
+
}), draggable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2608
|
+
"aria-hidden": true,
|
|
2609
|
+
onPointerDown: (e) => {
|
|
2610
|
+
e.stopPropagation();
|
|
2611
|
+
beginDrag(e, key, "resize", pe.startHours, pe.durationHours);
|
|
2612
|
+
},
|
|
2613
|
+
style: {
|
|
2614
|
+
position: "absolute",
|
|
2615
|
+
left: 0,
|
|
2616
|
+
right: 0,
|
|
2617
|
+
bottom: 0,
|
|
2618
|
+
height: 8,
|
|
2619
|
+
cursor: "ns-resize",
|
|
2620
|
+
touchAction: "none"
|
|
2621
|
+
}
|
|
2622
|
+
}) : null]
|
|
2623
|
+
}, idx);
|
|
2624
|
+
}),
|
|
2625
|
+
createBox?.resourceKey === resource.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2626
|
+
"aria-hidden": true,
|
|
2627
|
+
...slot("createGhost", {
|
|
2628
|
+
base: {
|
|
2629
|
+
position: "absolute",
|
|
2630
|
+
left: 1,
|
|
2631
|
+
right: 1,
|
|
2632
|
+
top: Math.min(createBox.startPx, createBox.curPx),
|
|
2633
|
+
height: Math.max(Math.abs(createBox.curPx - createBox.startPx), 2),
|
|
2634
|
+
opacity: .7,
|
|
2635
|
+
pointerEvents: "none",
|
|
2636
|
+
zIndex: 2
|
|
2637
|
+
},
|
|
2638
|
+
themed: {
|
|
2639
|
+
background: theme.rangeBackground,
|
|
2640
|
+
border: `1px solid ${theme.selectedBackground}`,
|
|
2641
|
+
borderRadius: 6
|
|
2345
2642
|
}
|
|
2346
|
-
})
|
|
2347
|
-
}
|
|
2348
|
-
|
|
2643
|
+
})
|
|
2644
|
+
}) : null
|
|
2645
|
+
]
|
|
2349
2646
|
})
|
|
2350
2647
|
}, resource.id);
|
|
2351
2648
|
})]
|
|
@@ -2420,84 +2717,123 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2420
2717
|
}),
|
|
2421
2718
|
children: resource.title ?? resource.id
|
|
2422
2719
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2720
|
+
...trackInteractionProps(resource),
|
|
2423
2721
|
...slot("track", { base: {
|
|
2424
2722
|
position: "relative",
|
|
2425
2723
|
width: trackWidth
|
|
2426
2724
|
} }),
|
|
2427
|
-
children: [
|
|
2428
|
-
"
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
inset: 0,
|
|
2433
|
-
pointerEvents: "none"
|
|
2434
|
-
},
|
|
2435
|
-
themed: { backgroundImage: gridLines }
|
|
2436
|
-
})
|
|
2437
|
-
}), positioned.map((pe, idx) => {
|
|
2438
|
-
const key = `${resource.id}:${idx}`;
|
|
2439
|
-
const active = drag?.key === key ? drag : null;
|
|
2440
|
-
const startH = active ? active.startHours : pe.startHours;
|
|
2441
|
-
const durH = active ? active.durationHours : pe.durationHours;
|
|
2442
|
-
const left = clamp(startH - startHour, 0, endHour - startHour) * hourWidth;
|
|
2443
|
-
const right = clamp(startH + durH - startHour, 0, endHour - startHour) * hourWidth;
|
|
2444
|
-
const width = Math.max(right - left, 2);
|
|
2445
|
-
const laneHeight = rowHeight / pe.columns;
|
|
2446
|
-
const onPress = () => onPressEvent?.(pe.event);
|
|
2447
|
-
const args = {
|
|
2448
|
-
event: pe.event,
|
|
2449
|
-
width,
|
|
2450
|
-
onPress
|
|
2451
|
-
};
|
|
2452
|
-
const draggable = !!onDragEvent;
|
|
2453
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2454
|
-
type: "button",
|
|
2455
|
-
onClick: draggable ? void 0 : onPress,
|
|
2456
|
-
"aria-label": pe.event.title,
|
|
2457
|
-
...dataState({ "data-dragging": !!active }),
|
|
2458
|
-
onPointerDown: draggable ? (e) => beginDrag(e, key, "move", pe.startHours, pe.durationHours) : void 0,
|
|
2459
|
-
onPointerMove: draggable ? moveDrag : void 0,
|
|
2460
|
-
onPointerUp: draggable ? (e) => endDrag(e, pe.event, onPress) : void 0,
|
|
2461
|
-
onPointerCancel: draggable ? cancelDrag : void 0,
|
|
2462
|
-
...slot("event", { base: {
|
|
2463
|
-
position: "absolute",
|
|
2464
|
-
left,
|
|
2465
|
-
width,
|
|
2466
|
-
top: pe.column * laneHeight,
|
|
2467
|
-
height: laneHeight,
|
|
2468
|
-
padding: 1,
|
|
2469
|
-
border: "none",
|
|
2470
|
-
background: "transparent",
|
|
2471
|
-
cursor: draggable ? "grab" : "pointer",
|
|
2472
|
-
touchAction: draggable ? "none" : "auto",
|
|
2473
|
-
font: "inherit",
|
|
2474
|
-
textAlign: "left",
|
|
2475
|
-
boxSizing: "border-box",
|
|
2476
|
-
zIndex: active ? 3 : 1,
|
|
2477
|
-
opacity: active ? .85 : 1
|
|
2478
|
-
} }),
|
|
2479
|
-
children: [Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...args }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultBar, {
|
|
2480
|
-
...args,
|
|
2481
|
-
theme,
|
|
2482
|
-
boxProps: slot("eventBox")
|
|
2483
|
-
}), draggable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2484
|
-
"aria-hidden": true,
|
|
2485
|
-
onPointerDown: (e) => {
|
|
2486
|
-
e.stopPropagation();
|
|
2487
|
-
beginDrag(e, key, "resize", pe.startHours, pe.durationHours);
|
|
2488
|
-
},
|
|
2489
|
-
style: {
|
|
2725
|
+
children: [
|
|
2726
|
+
bandsFor(resource).map((b) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2727
|
+
"aria-hidden": true,
|
|
2728
|
+
...slot("businessHours", {
|
|
2729
|
+
base: {
|
|
2490
2730
|
position: "absolute",
|
|
2491
2731
|
top: 0,
|
|
2492
2732
|
bottom: 0,
|
|
2493
|
-
|
|
2494
|
-
width:
|
|
2495
|
-
|
|
2496
|
-
|
|
2733
|
+
left: (b.start - startHour) * hourWidth,
|
|
2734
|
+
width: (b.end - b.start) * hourWidth,
|
|
2735
|
+
pointerEvents: "none",
|
|
2736
|
+
zIndex: 0
|
|
2737
|
+
},
|
|
2738
|
+
themed: { background: theme.outsideHoursBackground }
|
|
2739
|
+
})
|
|
2740
|
+
}, b.start)),
|
|
2741
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2742
|
+
"aria-hidden": true,
|
|
2743
|
+
...slot("gridLines", {
|
|
2744
|
+
base: {
|
|
2745
|
+
position: "absolute",
|
|
2746
|
+
inset: 0,
|
|
2747
|
+
pointerEvents: "none"
|
|
2748
|
+
},
|
|
2749
|
+
themed: { backgroundImage: gridLines }
|
|
2750
|
+
})
|
|
2751
|
+
}),
|
|
2752
|
+
positioned.map((pe, idx) => {
|
|
2753
|
+
const key = `${resource.id}:${idx}`;
|
|
2754
|
+
const active = drag?.key === key ? drag : null;
|
|
2755
|
+
const startH = active ? active.startHours : pe.startHours;
|
|
2756
|
+
const durH = active ? active.durationHours : pe.durationHours;
|
|
2757
|
+
const left = clamp(startH - startHour, 0, endHour - startHour) * hourWidth;
|
|
2758
|
+
const right = clamp(startH + durH - startHour, 0, endHour - startHour) * hourWidth;
|
|
2759
|
+
const width = Math.max(right - left, 2);
|
|
2760
|
+
const laneHeight = rowHeight / pe.columns;
|
|
2761
|
+
const onPress = () => onPressEvent?.(pe.event);
|
|
2762
|
+
const args = {
|
|
2763
|
+
event: pe.event,
|
|
2764
|
+
width,
|
|
2765
|
+
onPress
|
|
2766
|
+
};
|
|
2767
|
+
const draggable = !!onDragEvent;
|
|
2768
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2769
|
+
type: "button",
|
|
2770
|
+
onClick: draggable ? void 0 : onPress,
|
|
2771
|
+
"aria-label": pe.event.title,
|
|
2772
|
+
...dataState({ "data-dragging": !!active }),
|
|
2773
|
+
onPointerDown: draggable ? (e) => beginDrag(e, key, "move", pe.startHours, pe.durationHours) : void 0,
|
|
2774
|
+
onPointerMove: draggable ? moveDrag : void 0,
|
|
2775
|
+
onPointerUp: draggable ? (e) => endDrag(e, pe.event, onPress) : void 0,
|
|
2776
|
+
onPointerCancel: draggable ? cancelDrag : void 0,
|
|
2777
|
+
...slot("event", { base: {
|
|
2778
|
+
position: "absolute",
|
|
2779
|
+
left,
|
|
2780
|
+
width,
|
|
2781
|
+
top: pe.column * laneHeight,
|
|
2782
|
+
height: laneHeight,
|
|
2783
|
+
padding: 1,
|
|
2784
|
+
border: "none",
|
|
2785
|
+
background: "transparent",
|
|
2786
|
+
cursor: draggable ? "grab" : "pointer",
|
|
2787
|
+
touchAction: draggable ? "none" : "auto",
|
|
2788
|
+
font: "inherit",
|
|
2789
|
+
textAlign: "left",
|
|
2790
|
+
boxSizing: "border-box",
|
|
2791
|
+
zIndex: active ? 3 : 1,
|
|
2792
|
+
opacity: active ? .85 : 1
|
|
2793
|
+
} }),
|
|
2794
|
+
children: [Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...args }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultBar, {
|
|
2795
|
+
...args,
|
|
2796
|
+
theme,
|
|
2797
|
+
boxProps: slot("eventBox")
|
|
2798
|
+
}), draggable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2799
|
+
"aria-hidden": true,
|
|
2800
|
+
onPointerDown: (e) => {
|
|
2801
|
+
e.stopPropagation();
|
|
2802
|
+
beginDrag(e, key, "resize", pe.startHours, pe.durationHours);
|
|
2803
|
+
},
|
|
2804
|
+
style: {
|
|
2805
|
+
position: "absolute",
|
|
2806
|
+
top: 0,
|
|
2807
|
+
bottom: 0,
|
|
2808
|
+
right: 0,
|
|
2809
|
+
width: 8,
|
|
2810
|
+
cursor: "ew-resize",
|
|
2811
|
+
touchAction: "none"
|
|
2812
|
+
}
|
|
2813
|
+
}) : null]
|
|
2814
|
+
}, idx);
|
|
2815
|
+
}),
|
|
2816
|
+
createBox?.resourceKey === resource.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2817
|
+
"aria-hidden": true,
|
|
2818
|
+
...slot("createGhost", {
|
|
2819
|
+
base: {
|
|
2820
|
+
position: "absolute",
|
|
2821
|
+
top: 1,
|
|
2822
|
+
bottom: 1,
|
|
2823
|
+
left: Math.min(createBox.startPx, createBox.curPx),
|
|
2824
|
+
width: Math.max(Math.abs(createBox.curPx - createBox.startPx), 2),
|
|
2825
|
+
opacity: .7,
|
|
2826
|
+
pointerEvents: "none",
|
|
2827
|
+
zIndex: 2
|
|
2828
|
+
},
|
|
2829
|
+
themed: {
|
|
2830
|
+
background: theme.rangeBackground,
|
|
2831
|
+
border: `1px solid ${theme.selectedBackground}`,
|
|
2832
|
+
borderRadius: 6
|
|
2497
2833
|
}
|
|
2498
|
-
})
|
|
2499
|
-
}
|
|
2500
|
-
|
|
2834
|
+
})
|
|
2835
|
+
}) : null
|
|
2836
|
+
]
|
|
2501
2837
|
})]
|
|
2502
2838
|
}, resource.id);
|
|
2503
2839
|
})]
|
|
@@ -2513,6 +2849,7 @@ exports.MonthList = MonthList;
|
|
|
2513
2849
|
exports.MonthView = MonthView;
|
|
2514
2850
|
exports.ResourceTimeline = ResourceTimeline;
|
|
2515
2851
|
exports.TimeGrid = TimeGrid;
|
|
2852
|
+
exports.YearView = YearView;
|
|
2516
2853
|
Object.defineProperty(exports, "buildMonthGrid", {
|
|
2517
2854
|
enumerable: true,
|
|
2518
2855
|
get: function() {
|