@super-calendar/dom 2.14.2 → 2.16.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 +48 -0
- package/dist/index.d.mts +47 -26
- package/dist/index.d.ts +47 -26
- package/dist/index.js +1264 -452
- package/dist/index.mjs +1265 -453
- package/package.json +2 -2
- package/src/Calendar.tsx +13 -0
- package/src/DateRangePicker.tsx +60 -6
- package/src/EventActions.tsx +470 -0
- package/src/InertDiv.ts +7 -0
- package/src/MonthList.tsx +64 -38
- package/src/MonthView.tsx +14 -2
- package/src/ResourceTimeline.tsx +438 -98
- package/src/TimeGrid.tsx +305 -35
- package/src/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ let date_fns = require("date-fns");
|
|
|
4
4
|
let react = require("react");
|
|
5
5
|
let _super_calendar_core = require("@super-calendar/core");
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
-
|
|
7
|
+
// src/slots.ts
|
|
8
8
|
/** Join truthy class names (a dependency-free clsx-lite). */
|
|
9
9
|
function cn(...parts) {
|
|
10
10
|
return parts.filter(Boolean).join(" ") || void 0;
|
|
@@ -40,8 +40,7 @@ function dataState(flags) {
|
|
|
40
40
|
for (const key in flags) if (flags[key]) out[key] = "";
|
|
41
41
|
return out;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
//#region src/theme.ts
|
|
43
|
+
// src/theme.ts
|
|
45
44
|
const METRICS = {
|
|
46
45
|
cellHeight: 48,
|
|
47
46
|
dayBadgeSize: 34,
|
|
@@ -65,8 +64,7 @@ function mergeDomTheme(overrides, base = defaultDomTheme) {
|
|
|
65
64
|
...overrides
|
|
66
65
|
} : base;
|
|
67
66
|
}
|
|
68
|
-
|
|
69
|
-
//#region src/Agenda.tsx
|
|
67
|
+
// src/Agenda.tsx
|
|
70
68
|
function DefaultAgendaRow({ event, isAllDay, ampm = false, cardProps }) {
|
|
71
69
|
const time = (0, _super_calendar_core.eventTimeLabel)({
|
|
72
70
|
mode: "schedule",
|
|
@@ -234,8 +232,7 @@ function Agenda({ events, locale, ampm = false, activeDate, theme: themeOverride
|
|
|
234
232
|
}) : null]
|
|
235
233
|
});
|
|
236
234
|
}
|
|
237
|
-
|
|
238
|
-
//#region src/YearView.tsx
|
|
235
|
+
// src/YearView.tsx
|
|
239
236
|
/**
|
|
240
237
|
* A year at a glance: the twelve months as compact mini grids, with today
|
|
241
238
|
* highlighted and a dot under days that hold events. It's the view `Calendar`
|
|
@@ -545,8 +542,7 @@ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, labels:
|
|
|
545
542
|
})
|
|
546
543
|
});
|
|
547
544
|
}
|
|
548
|
-
|
|
549
|
-
//#region src/MonthView.tsx
|
|
545
|
+
// src/MonthView.tsx
|
|
550
546
|
const EMPTY_LAYOUT = {
|
|
551
547
|
segments: [],
|
|
552
548
|
laneCount: 0
|
|
@@ -844,7 +840,12 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
844
840
|
const initialFocusRef = (0, react.useRef)(initialFocus);
|
|
845
841
|
initialFocusRef.current = initialFocus;
|
|
846
842
|
const monthKey = (0, date_fns.format)(date, "yyyy-MM");
|
|
847
|
-
(0, react.
|
|
843
|
+
const focusedMonth = (0, react.useRef)(monthKey);
|
|
844
|
+
(0, react.useEffect)(() => {
|
|
845
|
+
if (monthKey === focusedMonth.current) return;
|
|
846
|
+
focusedMonth.current = monthKey;
|
|
847
|
+
setFocusedDate(initialFocusRef.current);
|
|
848
|
+
}, [monthKey]);
|
|
848
849
|
const [hoveredKey, setHoveredKey] = (0, react.useState)(null);
|
|
849
850
|
const gridRef = (0, react.useRef)(null);
|
|
850
851
|
const focusKey = (0, date_fns.format)(focusedDate, "yyyy-MM-dd");
|
|
@@ -1056,6 +1057,9 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1056
1057
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1057
1058
|
role: "gridcell",
|
|
1058
1059
|
"data-day": day.id,
|
|
1060
|
+
onFocus: (event) => {
|
|
1061
|
+
if (event.target === event.currentTarget) setFocusedDate(day.date);
|
|
1062
|
+
},
|
|
1059
1063
|
...dayData,
|
|
1060
1064
|
tabIndex: keyboardDayNavigation ? day.id === focusKey ? 0 : -1 : void 0,
|
|
1061
1065
|
"aria-disabled": day.isDisabled || void 0,
|
|
@@ -1266,11 +1270,14 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1266
1270
|
type: "button",
|
|
1267
1271
|
role: "gridcell",
|
|
1268
1272
|
"data-day": day.id,
|
|
1273
|
+
onFocus: (event) => {
|
|
1274
|
+
if (event.target === event.currentTarget) setFocusedDate(day.date);
|
|
1275
|
+
},
|
|
1269
1276
|
...dayData,
|
|
1270
1277
|
tabIndex: day.id === focusKey ? 0 : -1,
|
|
1271
1278
|
"aria-disabled": day.isDisabled || void 0,
|
|
1272
1279
|
"aria-label": label,
|
|
1273
|
-
"aria-
|
|
1280
|
+
"aria-selected": day.isSelected || day.isInRange,
|
|
1274
1281
|
...slot("day", dayCellDefault(day, theme, highlightWeekends)),
|
|
1275
1282
|
onClick: day.isDisabled ? void 0 : () => {
|
|
1276
1283
|
onPressDay?.(day.date);
|
|
@@ -1295,8 +1302,373 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1295
1302
|
]
|
|
1296
1303
|
});
|
|
1297
1304
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1305
|
+
// src/EventActions.tsx
|
|
1306
|
+
function moveFocus(event, container) {
|
|
1307
|
+
const buttons = [...container?.querySelectorAll("button") ?? []];
|
|
1308
|
+
const index = buttons.indexOf(document.activeElement);
|
|
1309
|
+
const target = event.key === "ArrowDown" ? buttons[(index + 1) % buttons.length] : event.key === "ArrowUp" ? buttons[index < 0 ? buttons.length - 1 : (index - 1 + buttons.length) % buttons.length] : event.key === "Home" ? buttons[0] : event.key === "End" ? buttons[buttons.length - 1] : void 0;
|
|
1310
|
+
if (!target) return;
|
|
1311
|
+
event.preventDefault();
|
|
1312
|
+
target.focus();
|
|
1313
|
+
}
|
|
1314
|
+
function describeEventDates(event) {
|
|
1315
|
+
const start = (0, date_fns.format)(event.start, "yyyy-MM-dd");
|
|
1316
|
+
const end = (0, date_fns.format)(event.end, "yyyy-MM-dd");
|
|
1317
|
+
return start === end ? start : `${start} - ${end}`;
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Open/close state for one component's actions dialog. `commit` applies an
|
|
1321
|
+
* action through the component's drag path and returns a matcher for the event
|
|
1322
|
+
* the consumer will render in its place, or null when the change was refused.
|
|
1323
|
+
* The dialog follows that replacement so repeated steps keep working, and
|
|
1324
|
+
* closes when its event disappears or can no longer be edited.
|
|
1325
|
+
*/
|
|
1326
|
+
function useEventActions(events, actionsFor, commit, getEventId) {
|
|
1327
|
+
const [openEvent, setOpenEvent] = (0, react.useState)(null);
|
|
1328
|
+
const [rejections, setRejections] = (0, react.useState)(0);
|
|
1329
|
+
const identity = (0, react.useRef)(null);
|
|
1330
|
+
const openRef = (0, react.useRef)(null);
|
|
1331
|
+
const show = (event) => {
|
|
1332
|
+
openRef.current = event;
|
|
1333
|
+
setOpenEvent(event);
|
|
1334
|
+
};
|
|
1335
|
+
const triggers = (0, react.useRef)(/* @__PURE__ */ new WeakMap());
|
|
1336
|
+
const dialogRef = (0, react.useRef)(null);
|
|
1337
|
+
const rootRef = (0, react.useRef)(null);
|
|
1338
|
+
const pending = (0, react.useRef)(null);
|
|
1339
|
+
const current = () => {
|
|
1340
|
+
const event = openRef.current;
|
|
1341
|
+
if (!event) return void 0;
|
|
1342
|
+
if (identity.current) {
|
|
1343
|
+
if (!getEventId) return void 0;
|
|
1344
|
+
const id = identity.current.id;
|
|
1345
|
+
const matches = events.filter((candidate) => getEventId(candidate) === id);
|
|
1346
|
+
return matches.length === 1 ? matches[0] : void 0;
|
|
1347
|
+
}
|
|
1348
|
+
if (getEventId) return void 0;
|
|
1349
|
+
if (events.includes(event)) return event;
|
|
1350
|
+
const committed = pending.current;
|
|
1351
|
+
if (committed?.from !== event) return void 0;
|
|
1352
|
+
if (committed.events.some((previous) => previous !== event && !events.includes(previous))) return void 0;
|
|
1353
|
+
const replacements = events.filter((candidate) => !committed.events.includes(candidate) && committed.matches(candidate));
|
|
1354
|
+
return replacements.length === 1 ? replacements[0] : void 0;
|
|
1355
|
+
};
|
|
1356
|
+
const close = (restoreFocus, fallbackToRoot = false) => {
|
|
1357
|
+
const event = openRef.current;
|
|
1358
|
+
if (!event) return;
|
|
1359
|
+
const shown = current() ?? event;
|
|
1360
|
+
pending.current = null;
|
|
1361
|
+
const dialog = dialogRef.current;
|
|
1362
|
+
if (dialog?.open) {
|
|
1363
|
+
if (typeof dialog.close === "function") dialog.close();
|
|
1364
|
+
else dialog.removeAttribute("open");
|
|
1365
|
+
}
|
|
1366
|
+
if (restoreFocus) {
|
|
1367
|
+
const trigger = triggers.current.get(shown);
|
|
1368
|
+
(fallbackToRoot ? rootRef.current : trigger?.isConnected ? trigger : [...rootRef.current?.querySelectorAll("button:not(:disabled), [tabindex=\"0\"]") ?? []].find((element) => !dialog?.contains(element)) ?? rootRef.current)?.focus();
|
|
1369
|
+
}
|
|
1370
|
+
show(null);
|
|
1371
|
+
};
|
|
1372
|
+
(0, react.useEffect)(() => {
|
|
1373
|
+
if (!openRef.current) return;
|
|
1374
|
+
const next = current();
|
|
1375
|
+
if (pending.current && pending.current.events !== events) pending.current = null;
|
|
1376
|
+
if (next && actionsFor(next).length > 0) {
|
|
1377
|
+
if (next !== openEvent) show(next);
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
close(document.activeElement === document.body || !!dialogRef.current?.contains(document.activeElement), true);
|
|
1381
|
+
});
|
|
1382
|
+
const run = (actionId) => {
|
|
1383
|
+
const event = current();
|
|
1384
|
+
if (!event) return;
|
|
1385
|
+
openRef.current = event;
|
|
1386
|
+
pending.current = null;
|
|
1387
|
+
const matches = commit(event, actionId);
|
|
1388
|
+
setRejections((count) => matches ? 0 : count + 1);
|
|
1389
|
+
if (matches) pending.current = {
|
|
1390
|
+
from: event,
|
|
1391
|
+
events,
|
|
1392
|
+
matches
|
|
1393
|
+
};
|
|
1394
|
+
};
|
|
1395
|
+
const select = (event, trigger) => {
|
|
1396
|
+
const id = getEventId?.(event);
|
|
1397
|
+
identity.current = typeof id === "string" || typeof id === "number" ? { id } : null;
|
|
1398
|
+
setRejections(0);
|
|
1399
|
+
triggers.current.set(event, trigger);
|
|
1400
|
+
show(event);
|
|
1401
|
+
};
|
|
1402
|
+
return {
|
|
1403
|
+
openEvent,
|
|
1404
|
+
close,
|
|
1405
|
+
run,
|
|
1406
|
+
select,
|
|
1407
|
+
dialogRef,
|
|
1408
|
+
rootRef,
|
|
1409
|
+
rejections
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
function EventActionsMenu({ events, label, labelFor, descriptionFor, onSelect, rootRef, slot, theme }) {
|
|
1413
|
+
const [expanded, setExpanded] = (0, react.useState)(false);
|
|
1414
|
+
const trigger = (0, react.useRef)(null);
|
|
1415
|
+
const listRef = (0, react.useRef)(null);
|
|
1416
|
+
(0, react.useEffect)(() => {
|
|
1417
|
+
if (expanded) listRef.current?.querySelector("button")?.focus();
|
|
1418
|
+
}, [expanded]);
|
|
1419
|
+
const id = (0, react.useId)();
|
|
1420
|
+
const focused = (0, react.useRef)(null);
|
|
1421
|
+
const keys = (0, react.useRef)(/* @__PURE__ */ new WeakMap());
|
|
1422
|
+
const nextKey = (0, react.useRef)(0);
|
|
1423
|
+
const keyFor = (event) => {
|
|
1424
|
+
let key = keys.current.get(event);
|
|
1425
|
+
if (key === void 0) {
|
|
1426
|
+
key = nextKey.current++;
|
|
1427
|
+
keys.current.set(event, key);
|
|
1428
|
+
}
|
|
1429
|
+
return key;
|
|
1430
|
+
};
|
|
1431
|
+
(0, react.useEffect)(() => {
|
|
1432
|
+
const previous = focused.current;
|
|
1433
|
+
if (!previous || document.activeElement !== document.body) return;
|
|
1434
|
+
(previous.isConnected ? previous : trigger.current ?? rootRef.current)?.focus();
|
|
1435
|
+
});
|
|
1436
|
+
if (!events.length) return null;
|
|
1437
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1438
|
+
onFocusCapture: (e) => {
|
|
1439
|
+
focused.current = e.target;
|
|
1440
|
+
},
|
|
1441
|
+
onBlurCapture: (e) => {
|
|
1442
|
+
if (e.relatedTarget && !e.currentTarget.contains(e.relatedTarget)) focused.current = null;
|
|
1443
|
+
},
|
|
1444
|
+
onKeyDown: (e) => {
|
|
1445
|
+
if (!expanded) return;
|
|
1446
|
+
if (e.key !== "Escape") {
|
|
1447
|
+
moveFocus(e, listRef.current);
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
e.preventDefault();
|
|
1451
|
+
e.stopPropagation();
|
|
1452
|
+
setExpanded(false);
|
|
1453
|
+
trigger.current?.focus();
|
|
1454
|
+
},
|
|
1455
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1456
|
+
ref: trigger,
|
|
1457
|
+
id,
|
|
1458
|
+
type: "button",
|
|
1459
|
+
"aria-expanded": expanded,
|
|
1460
|
+
"aria-controls": expanded ? id + "-list" : void 0,
|
|
1461
|
+
onClick: () => setExpanded(!expanded),
|
|
1462
|
+
...slot("eventActionsTrigger", {
|
|
1463
|
+
base: {
|
|
1464
|
+
minHeight: 32,
|
|
1465
|
+
font: "inherit",
|
|
1466
|
+
cursor: "pointer"
|
|
1467
|
+
},
|
|
1468
|
+
themed: {
|
|
1469
|
+
margin: "4px 0",
|
|
1470
|
+
padding: "4px 10px",
|
|
1471
|
+
border: `1px solid ${theme.gridLine}`,
|
|
1472
|
+
borderRadius: 6,
|
|
1473
|
+
background: theme.surface,
|
|
1474
|
+
color: theme.text
|
|
1475
|
+
}
|
|
1476
|
+
}),
|
|
1477
|
+
children: label
|
|
1478
|
+
}), expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1479
|
+
ref: listRef,
|
|
1480
|
+
id: id + "-list",
|
|
1481
|
+
role: "group",
|
|
1482
|
+
"aria-labelledby": id,
|
|
1483
|
+
...slot("eventActionsList", {
|
|
1484
|
+
base: {
|
|
1485
|
+
display: "flex",
|
|
1486
|
+
flexDirection: "column",
|
|
1487
|
+
gap: 4,
|
|
1488
|
+
maxHeight: "min(20rem, 50vh)",
|
|
1489
|
+
overflowY: "auto"
|
|
1490
|
+
},
|
|
1491
|
+
themed: {
|
|
1492
|
+
padding: 4,
|
|
1493
|
+
background: theme.surface,
|
|
1494
|
+
border: `1px solid ${theme.gridLine}`,
|
|
1495
|
+
borderRadius: 6
|
|
1496
|
+
}
|
|
1497
|
+
}),
|
|
1498
|
+
children: events.map((event, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1499
|
+
type: "button",
|
|
1500
|
+
"aria-haspopup": "dialog",
|
|
1501
|
+
"aria-label": labelFor(event),
|
|
1502
|
+
"aria-describedby": id + "-" + index,
|
|
1503
|
+
onClick: () => {
|
|
1504
|
+
setExpanded(false);
|
|
1505
|
+
focused.current = null;
|
|
1506
|
+
onSelect(event, trigger.current);
|
|
1507
|
+
},
|
|
1508
|
+
...slot("eventAction", {
|
|
1509
|
+
base: {
|
|
1510
|
+
minHeight: 32,
|
|
1511
|
+
flexShrink: 0,
|
|
1512
|
+
overflowWrap: "anywhere",
|
|
1513
|
+
font: "inherit",
|
|
1514
|
+
cursor: "pointer",
|
|
1515
|
+
textAlign: "left"
|
|
1516
|
+
},
|
|
1517
|
+
themed: {
|
|
1518
|
+
padding: "6px 10px",
|
|
1519
|
+
border: `1px solid ${theme.gridLine}`,
|
|
1520
|
+
borderRadius: 6,
|
|
1521
|
+
background: theme.surface,
|
|
1522
|
+
color: theme.text
|
|
1523
|
+
}
|
|
1524
|
+
}),
|
|
1525
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: labelFor(event) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
|
|
1526
|
+
id: id + "-" + index,
|
|
1527
|
+
style: { display: "block" },
|
|
1528
|
+
children: descriptionFor(event)
|
|
1529
|
+
})]
|
|
1530
|
+
}, keyFor(event)))
|
|
1531
|
+
}) : null]
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
/** The modal dialog listing an event's move and resize actions. */
|
|
1535
|
+
function EventActionsDialog({ dialogRef, title, description, actions, closeLabel, rejectedLabel, rejections, onAction, onClose, slot, theme }) {
|
|
1536
|
+
const titleId = (0, react.useId)();
|
|
1537
|
+
const descriptionId = (0, react.useId)();
|
|
1538
|
+
(0, react.useEffect)(() => {
|
|
1539
|
+
const dialog = dialogRef.current;
|
|
1540
|
+
if (!dialog || dialog.open) return;
|
|
1541
|
+
if (typeof dialog.showModal === "function") dialog.showModal();
|
|
1542
|
+
else dialog.setAttribute("open", "");
|
|
1543
|
+
}, [dialogRef]);
|
|
1544
|
+
(0, react.useEffect)(() => {
|
|
1545
|
+
const dialog = dialogRef.current;
|
|
1546
|
+
if (dialog && !dialog.contains(document.activeElement)) dialog.querySelector("button")?.focus();
|
|
1547
|
+
});
|
|
1548
|
+
const buttonSlot = (available) => slot("eventAction", {
|
|
1549
|
+
base: {
|
|
1550
|
+
display: "block",
|
|
1551
|
+
width: "100%",
|
|
1552
|
+
minHeight: 32,
|
|
1553
|
+
boxSizing: "border-box",
|
|
1554
|
+
textAlign: "left",
|
|
1555
|
+
font: "inherit",
|
|
1556
|
+
cursor: available ? "pointer" : "default"
|
|
1557
|
+
},
|
|
1558
|
+
themed: {
|
|
1559
|
+
padding: "6px 10px",
|
|
1560
|
+
border: `1px solid ${theme.gridLine}`,
|
|
1561
|
+
borderRadius: 8,
|
|
1562
|
+
background: theme.surface,
|
|
1563
|
+
color: theme.text,
|
|
1564
|
+
fontSize: 13,
|
|
1565
|
+
opacity: available ? 1 : .5
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dialog", {
|
|
1569
|
+
ref: dialogRef,
|
|
1570
|
+
"aria-labelledby": titleId,
|
|
1571
|
+
"aria-describedby": descriptionId,
|
|
1572
|
+
onClose: () => onClose(),
|
|
1573
|
+
onCancel: (e) => {
|
|
1574
|
+
e.preventDefault();
|
|
1575
|
+
onClose();
|
|
1576
|
+
},
|
|
1577
|
+
onClick: (e) => {
|
|
1578
|
+
if (e.target === e.currentTarget) onClose();
|
|
1579
|
+
},
|
|
1580
|
+
onKeyDown: (e) => {
|
|
1581
|
+
if (e.key === "PageUp" || e.key === "PageDown") e.stopPropagation();
|
|
1582
|
+
if (e.key === "Escape") {
|
|
1583
|
+
e.preventDefault();
|
|
1584
|
+
e.stopPropagation();
|
|
1585
|
+
onClose();
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1588
|
+
moveFocus(e, e.currentTarget);
|
|
1589
|
+
},
|
|
1590
|
+
...slot("eventActions", {
|
|
1591
|
+
base: {
|
|
1592
|
+
margin: "auto",
|
|
1593
|
+
overflowWrap: "anywhere",
|
|
1594
|
+
padding: 0,
|
|
1595
|
+
width: "max-content",
|
|
1596
|
+
maxWidth: "min(22rem, calc(100vw - 32px))",
|
|
1597
|
+
maxHeight: "calc(100vh - 32px)",
|
|
1598
|
+
overflowY: "auto",
|
|
1599
|
+
boxSizing: "border-box"
|
|
1600
|
+
},
|
|
1601
|
+
themed: {
|
|
1602
|
+
fontFamily: theme.fontFamily,
|
|
1603
|
+
background: theme.surface,
|
|
1604
|
+
color: theme.text,
|
|
1605
|
+
border: `1px solid ${theme.gridLine}`,
|
|
1606
|
+
borderRadius: 12,
|
|
1607
|
+
boxShadow: "0 8px 24px rgba(0,0,0,0.18)"
|
|
1608
|
+
}
|
|
1609
|
+
}),
|
|
1610
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1611
|
+
style: {
|
|
1612
|
+
display: "flex",
|
|
1613
|
+
flexDirection: "column",
|
|
1614
|
+
gap: 6,
|
|
1615
|
+
padding: 12
|
|
1616
|
+
},
|
|
1617
|
+
children: [
|
|
1618
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1619
|
+
id: titleId,
|
|
1620
|
+
style: {
|
|
1621
|
+
margin: 0,
|
|
1622
|
+
fontWeight: 600,
|
|
1623
|
+
fontSize: 14
|
|
1624
|
+
},
|
|
1625
|
+
children: title
|
|
1626
|
+
}),
|
|
1627
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1628
|
+
id: descriptionId,
|
|
1629
|
+
"aria-live": "polite",
|
|
1630
|
+
style: {
|
|
1631
|
+
margin: "0 0 4px",
|
|
1632
|
+
fontSize: 12,
|
|
1633
|
+
color: theme.textMuted
|
|
1634
|
+
},
|
|
1635
|
+
children: description
|
|
1636
|
+
}),
|
|
1637
|
+
actions.map((action) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1638
|
+
type: "button",
|
|
1639
|
+
"data-action": action.id,
|
|
1640
|
+
"aria-disabled": action.available ? void 0 : true,
|
|
1641
|
+
onClick: () => {
|
|
1642
|
+
if (action.available) onAction(action.id);
|
|
1643
|
+
},
|
|
1644
|
+
...buttonSlot(action.available),
|
|
1645
|
+
children: action.label
|
|
1646
|
+
}, action.id)),
|
|
1647
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1648
|
+
role: "status",
|
|
1649
|
+
"aria-atomic": "true",
|
|
1650
|
+
style: { fontSize: 13 },
|
|
1651
|
+
children: rejections > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: rejectedLabel }, rejections) : null
|
|
1652
|
+
}),
|
|
1653
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1654
|
+
type: "button",
|
|
1655
|
+
"data-action": "close",
|
|
1656
|
+
onClick: () => onClose(),
|
|
1657
|
+
...buttonSlot(true),
|
|
1658
|
+
children: closeLabel
|
|
1659
|
+
})
|
|
1660
|
+
]
|
|
1661
|
+
})
|
|
1662
|
+
});
|
|
1663
|
+
}
|
|
1664
|
+
// src/InertDiv.ts
|
|
1665
|
+
function InertDiv(props) {
|
|
1666
|
+
return (0, react.createElement)("div", {
|
|
1667
|
+
...props,
|
|
1668
|
+
inert: props.inert ? "inert" : void 0
|
|
1669
|
+
});
|
|
1670
|
+
}
|
|
1671
|
+
// src/touch.ts
|
|
1300
1672
|
function waitForHold(grab, delay, threshold, onHold, onTap, onCancel) {
|
|
1301
1673
|
const detach = () => {
|
|
1302
1674
|
clearTimeout(timer);
|
|
@@ -1334,13 +1706,26 @@ function waitForHold(grab, delay, threshold, onHold, onTap, onCancel) {
|
|
|
1334
1706
|
document.addEventListener("pointerdown", anotherPointer);
|
|
1335
1707
|
return cancel;
|
|
1336
1708
|
}
|
|
1337
|
-
|
|
1338
|
-
//#region src/TimeGrid.tsx
|
|
1709
|
+
// src/TimeGrid.tsx
|
|
1339
1710
|
const GUTTER_WIDTH$1 = 56;
|
|
1340
1711
|
const HOURS_PER_DAY = 24;
|
|
1341
1712
|
const DEFAULT_MIN_EVENT_HEIGHT = 14;
|
|
1342
1713
|
const DEFAULT_EVENT_GAP = 1;
|
|
1343
1714
|
const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
1715
|
+
const CREATE_PREVIEW_MIN_HEIGHT = 2;
|
|
1716
|
+
function createPreviewPlacement(topPx, heightPx, gridHeight) {
|
|
1717
|
+
const start = clamp$1(topPx, 0, gridHeight);
|
|
1718
|
+
const end = clamp$1(topPx + heightPx, 0, gridHeight);
|
|
1719
|
+
const height = Math.min(gridHeight, Math.max(end - start, CREATE_PREVIEW_MIN_HEIGHT));
|
|
1720
|
+
const top = Math.min(start, gridHeight - height);
|
|
1721
|
+
return top + height / 2 > gridHeight / 2 ? {
|
|
1722
|
+
bottom: gridHeight - top - height,
|
|
1723
|
+
height
|
|
1724
|
+
} : {
|
|
1725
|
+
top,
|
|
1726
|
+
height
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1344
1729
|
const EDGE_ZONE = 32;
|
|
1345
1730
|
const EDGE_DWELL_MS = 600;
|
|
1346
1731
|
const EDGE_REPEAT_MS = 600;
|
|
@@ -1443,7 +1828,7 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
|
|
|
1443
1828
|
* ```
|
|
1444
1829
|
*/
|
|
1445
1830
|
const TimeGrid = (0, react.forwardRef)(TimeGridInner);
|
|
1446
|
-
function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, dragStepMinutes = 15, touchDragDelay = 300, touchDragThreshold = 8, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, labels: labelsProp, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }, ref) {
|
|
1831
|
+
function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, dragStepMinutes = 15, touchDragDelay = 300, touchDragThreshold = 8, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, labels: labelsProp, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, renderCreateGhost, onDragStart, onDragEvent, getEventId, onChangeDate, className, style, classNames, styles }, ref) {
|
|
1447
1832
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
1448
1833
|
const labels = (0, react.useMemo)(() => (0, _super_calendar_core.resolveCalendarLabels)(labelsProp), [labelsProp]);
|
|
1449
1834
|
const slot = createSlots({
|
|
@@ -1459,6 +1844,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1459
1844
|
const windowHours = windowEnd - windowStart;
|
|
1460
1845
|
const gutterWidth = hideHours ? 0 : GUTTER_WIDTH$1;
|
|
1461
1846
|
const RenderBackground = renderBackgroundEvent;
|
|
1847
|
+
const RenderCreateGhost = renderCreateGhost;
|
|
1462
1848
|
const visibleHours = (0, react.useMemo)(() => Array.from({ length: windowHours }, (_, i) => windowStart + i), [windowStart, windowHours]);
|
|
1463
1849
|
const now = (0, _super_calendar_core.useNow)(showNowIndicator, {
|
|
1464
1850
|
now: nowProp,
|
|
@@ -1477,6 +1863,21 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1477
1863
|
};
|
|
1478
1864
|
const [createBox, setCreateBox] = (0, react.useState)(null);
|
|
1479
1865
|
const createOrigin = (0, react.useRef)(null);
|
|
1866
|
+
const createActive = createBox !== null;
|
|
1867
|
+
(0, react.useEffect)(() => {
|
|
1868
|
+
if (!createActive) return;
|
|
1869
|
+
const onScroll = () => {
|
|
1870
|
+
const origin = createOrigin.current;
|
|
1871
|
+
if (!origin) return;
|
|
1872
|
+
const curPx = origin.clientY - origin.el.getBoundingClientRect().top;
|
|
1873
|
+
setCreateBox((current) => current && current.curPx !== curPx ? {
|
|
1874
|
+
...current,
|
|
1875
|
+
curPx
|
|
1876
|
+
} : current);
|
|
1877
|
+
};
|
|
1878
|
+
window.addEventListener("scroll", onScroll, true);
|
|
1879
|
+
return () => window.removeEventListener("scroll", onScroll, true);
|
|
1880
|
+
}, [createActive]);
|
|
1480
1881
|
const cellTouchRef = (0, react.useRef)(null);
|
|
1481
1882
|
const cellEnabled = !!onPressCell || !!onCreateEvent;
|
|
1482
1883
|
const days = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays, false, void 0, hiddenDays), [
|
|
@@ -1521,6 +1922,62 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1521
1922
|
onChangeDateRef.current = onChangeDate;
|
|
1522
1923
|
const onDragEventRef = (0, react.useRef)(onDragEvent);
|
|
1523
1924
|
onDragEventRef.current = onDragEvent && eventOverlap === false ? (event, start, end) => (0, _super_calendar_core.overlapsOtherEvents)(events, event, start, end) ? false : onDragEvent(event, start, end) : onDragEvent;
|
|
1925
|
+
const editability = (event) => {
|
|
1926
|
+
const editable = !!onDragEvent && event.draggable !== false;
|
|
1927
|
+
return {
|
|
1928
|
+
canMove: editable && (event.startEditable ?? eventStartEditable),
|
|
1929
|
+
canResize: editable && (event.durationEditable ?? eventDurationEditable)
|
|
1930
|
+
};
|
|
1931
|
+
};
|
|
1932
|
+
const eventLabel = (event) => eventAccessibilityLabel ? eventAccessibilityLabel(event, {
|
|
1933
|
+
mode,
|
|
1934
|
+
isAllDay: false,
|
|
1935
|
+
ampm
|
|
1936
|
+
}) : (0, _super_calendar_core.eventAccessibilityLabel)({
|
|
1937
|
+
title: event.title,
|
|
1938
|
+
isAllDay: false,
|
|
1939
|
+
start: event.start,
|
|
1940
|
+
end: event.end,
|
|
1941
|
+
ampm,
|
|
1942
|
+
labels
|
|
1943
|
+
});
|
|
1944
|
+
const eventDescription = (event) => `${describeEventDates(event)}, ${eventLabel(event)}`;
|
|
1945
|
+
const pageDays = (0, _super_calendar_core.pageStepDays)(mode, date, weekStartsOn, numberOfDays);
|
|
1946
|
+
const actionDelta = (id) => {
|
|
1947
|
+
const page = pageDays * HOURS_PER_DAY * 60;
|
|
1948
|
+
switch (id) {
|
|
1949
|
+
case "move-later": return [snapMinutes, snapMinutes];
|
|
1950
|
+
case "move-earlier": return [-snapMinutes, -snapMinutes];
|
|
1951
|
+
case "extend": return [0, snapMinutes];
|
|
1952
|
+
case "shorten": return [0, -snapMinutes];
|
|
1953
|
+
case "move-next-page": return [page, page];
|
|
1954
|
+
case "move-previous-page": return [-page, -page];
|
|
1955
|
+
default: return null;
|
|
1956
|
+
}
|
|
1957
|
+
};
|
|
1958
|
+
const editActions = (event) => {
|
|
1959
|
+
if ((0, _super_calendar_core.isAllDayEvent)(event) || (0, _super_calendar_core.isBackgroundEvent)(event)) return [];
|
|
1960
|
+
const { canMove, canResize } = editability(event);
|
|
1961
|
+
const action = (id, label) => {
|
|
1962
|
+
const [startDelta, endDelta] = actionDelta(id) ?? [0, 0];
|
|
1963
|
+
return {
|
|
1964
|
+
id,
|
|
1965
|
+
label,
|
|
1966
|
+
available: (0, _super_calendar_core.resolveDraggedBounds)(event.start, event.end, startDelta, endDelta, snapMinutes) !== null
|
|
1967
|
+
};
|
|
1968
|
+
};
|
|
1969
|
+
return [
|
|
1970
|
+
...canMove ? [action("move-later", labels.moveLater(snapMinutes)), action("move-earlier", labels.moveEarlier(snapMinutes))] : [],
|
|
1971
|
+
...canResize ? [action("extend", labels.extend(snapMinutes)), action("shorten", labels.shorten(snapMinutes))] : [],
|
|
1972
|
+
...canMove ? [action("move-next-page", labels.moveToNextPage(pageDays, mode)), action("move-previous-page", labels.moveToPreviousPage(pageDays, mode))] : []
|
|
1973
|
+
];
|
|
1974
|
+
};
|
|
1975
|
+
const eventActions = useEventActions(events, editActions, (event, id) => {
|
|
1976
|
+
const delta = actionDelta(id);
|
|
1977
|
+
const next = delta && (0, _super_calendar_core.resolveDraggedBounds)(event.start, event.end, delta[0], delta[1], snapMinutes);
|
|
1978
|
+
if (!next || onDragEventRef.current?.(event, next.start, next.end) === false) return null;
|
|
1979
|
+
return (candidate) => candidate !== event && candidate.start.getTime() === next.start.getTime() && candidate.end.getTime() === next.end.getTime() && candidate.title === event.title;
|
|
1980
|
+
}, getEventId);
|
|
1524
1981
|
const allDayByDay = (0, react.useMemo)(() => days.map((day) => {
|
|
1525
1982
|
const dayStart = (0, date_fns.startOfDay)(day);
|
|
1526
1983
|
const dayEnd = (0, date_fns.addDays)(dayStart, 1);
|
|
@@ -1877,15 +2334,21 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1877
2334
|
try {
|
|
1878
2335
|
el.setPointerCapture?.(e.pointerId);
|
|
1879
2336
|
} catch {}
|
|
2337
|
+
const dayTime = days[dayIndex].getTime();
|
|
1880
2338
|
createOrigin.current = {
|
|
2339
|
+
pointerId: e.pointerId,
|
|
2340
|
+
clientY: e.clientY,
|
|
1881
2341
|
el,
|
|
1882
2342
|
dayIndex,
|
|
2343
|
+
dayTime,
|
|
2344
|
+
creating: !!onCreateEvent,
|
|
1883
2345
|
startPx
|
|
1884
2346
|
};
|
|
1885
2347
|
setCreateBox({
|
|
1886
2348
|
dayIndex,
|
|
1887
|
-
|
|
1888
|
-
|
|
2349
|
+
dayTime,
|
|
2350
|
+
startPx,
|
|
2351
|
+
curPx: startPx
|
|
1889
2352
|
});
|
|
1890
2353
|
};
|
|
1891
2354
|
const moveCreate = (e) => {
|
|
@@ -1893,11 +2356,12 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1893
2356
|
if (touch && e.pointerId === touch.pointerId && Math.hypot(e.clientX - touch.x, e.clientY - touch.y) > CELL_TOUCH_SLOP_PX) cellTouchRef.current = null;
|
|
1894
2357
|
const o = createOrigin.current;
|
|
1895
2358
|
if (!o) return;
|
|
1896
|
-
|
|
2359
|
+
o.clientY = e.clientY;
|
|
1897
2360
|
setCreateBox({
|
|
1898
2361
|
dayIndex: o.dayIndex,
|
|
1899
|
-
|
|
1900
|
-
|
|
2362
|
+
dayTime: o.dayTime,
|
|
2363
|
+
startPx: o.startPx,
|
|
2364
|
+
curPx: pxFromTop(o.el, e.clientY)
|
|
1901
2365
|
});
|
|
1902
2366
|
};
|
|
1903
2367
|
const endCreate = (e) => {
|
|
@@ -1929,11 +2393,43 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1929
2393
|
const at = (0, _super_calendar_core.cellRangeFromDrag)(day, px, px, hourHeightRef.current, windowStart, snapMinutes);
|
|
1930
2394
|
if (at) onPressCell(at.start);
|
|
1931
2395
|
};
|
|
1932
|
-
const
|
|
1933
|
-
|
|
2396
|
+
const clearCreate = (0, react.useCallback)(() => {
|
|
2397
|
+
const previous = createOrigin.current;
|
|
1934
2398
|
createOrigin.current = null;
|
|
1935
2399
|
setCreateBox(null);
|
|
2400
|
+
try {
|
|
2401
|
+
previous?.el.releasePointerCapture?.(previous.pointerId);
|
|
2402
|
+
} catch {}
|
|
2403
|
+
}, []);
|
|
2404
|
+
const cancelCreate = () => {
|
|
2405
|
+
cellTouchRef.current = null;
|
|
2406
|
+
clearCreate();
|
|
2407
|
+
};
|
|
2408
|
+
const loseCreateCapture = (e) => {
|
|
2409
|
+
if (createOrigin.current?.pointerId !== e.pointerId) return;
|
|
2410
|
+
clearCreate();
|
|
1936
2411
|
};
|
|
2412
|
+
(0, react.useEffect)(() => {
|
|
2413
|
+
const onKeyDown = (event) => {
|
|
2414
|
+
if (event.key !== "Escape" || !createOrigin.current) return;
|
|
2415
|
+
event.preventDefault();
|
|
2416
|
+
event.stopPropagation();
|
|
2417
|
+
clearCreate();
|
|
2418
|
+
};
|
|
2419
|
+
document.addEventListener("keydown", onKeyDown);
|
|
2420
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
2421
|
+
}, [clearCreate]);
|
|
2422
|
+
const liveRange = createBox && RenderCreateGhost && onCreateEvent && days[createBox.dayIndex]?.getTime() === createBox.dayTime ? (0, _super_calendar_core.cellRangeFromDrag)(days[createBox.dayIndex], createBox.startPx, createBox.curPx, hourHeight, windowStart, snapMinutes) : null;
|
|
2423
|
+
const liveStart = liveRange?.start.getTime();
|
|
2424
|
+
const liveEnd = liveRange?.end.getTime();
|
|
2425
|
+
const createRange = (0, react.useMemo)(() => liveStart === void 0 || liveEnd === void 0 ? null : {
|
|
2426
|
+
start: new Date(liveStart),
|
|
2427
|
+
end: new Date(liveEnd)
|
|
2428
|
+
}, [liveStart, liveEnd]);
|
|
2429
|
+
(0, react.useEffect)(() => {
|
|
2430
|
+
const origin = createOrigin.current;
|
|
2431
|
+
if (origin && (!origin.el.isConnected || !cellEnabled || origin.creating && !onCreateEvent || days[origin.dayIndex]?.getTime() !== origin.dayTime)) clearCreate();
|
|
2432
|
+
});
|
|
1937
2433
|
const positionedByDay = (0, react.useMemo)(() => days.map((day) => (0, _super_calendar_core.layoutDayEvents)(events, day)), [days, events]);
|
|
1938
2434
|
const moveOrigin = dragOrigin.current;
|
|
1939
2435
|
const heldEvent = draggedRef.current?.event;
|
|
@@ -2060,7 +2556,10 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2060
2556
|
timeslots,
|
|
2061
2557
|
theme.gridLine
|
|
2062
2558
|
]);
|
|
2559
|
+
const openActionsEvent = eventActions.openEvent;
|
|
2063
2560
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2561
|
+
ref: eventActions.rootRef,
|
|
2562
|
+
tabIndex: -1,
|
|
2064
2563
|
className,
|
|
2065
2564
|
style: {
|
|
2066
2565
|
fontFamily: theme.fontFamily,
|
|
@@ -2070,6 +2569,16 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2070
2569
|
...style
|
|
2071
2570
|
},
|
|
2072
2571
|
children: [
|
|
2572
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EventActionsMenu, {
|
|
2573
|
+
events: [...new Set(positionedByDay.flat().filter((pe) => pe.startHours < windowEnd && pe.startHours + pe.durationHours > windowStart).map((pe) => pe.event))].filter((event) => editActions(event).length > 0),
|
|
2574
|
+
label: labels.editEvents,
|
|
2575
|
+
labelFor: (event) => labels.eventActions(event.title ?? ""),
|
|
2576
|
+
descriptionFor: eventDescription,
|
|
2577
|
+
onSelect: eventActions.select,
|
|
2578
|
+
rootRef: eventActions.rootRef,
|
|
2579
|
+
slot,
|
|
2580
|
+
theme
|
|
2581
|
+
}),
|
|
2073
2582
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2074
2583
|
...slot("header", {
|
|
2075
2584
|
base: { display: "flex" },
|
|
@@ -2281,7 +2790,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2281
2790
|
const showNow = showNowIndicator && (0, _super_calendar_core.isSameCalendarDay)(day, now) && nowHours >= windowStart && nowHours <= windowEnd;
|
|
2282
2791
|
const nowTop = (nowHours - windowStart) * hourHeight;
|
|
2283
2792
|
const bands = bandsByDay[dayIndex];
|
|
2284
|
-
const ghost = createBox?.dayIndex === dayIndex ? createBox : null;
|
|
2793
|
+
const ghost = createBox?.dayIndex === dayIndex && createBox.dayTime === day.getTime() ? createBox : null;
|
|
2794
|
+
const ghostRange = ghost ? createRange : null;
|
|
2285
2795
|
const spill = multiDayMove ? null : spillPreviewFor(dayIndex);
|
|
2286
2796
|
const moveSegment = multiDayMove ? (0, _super_calendar_core.layoutDayEvents)([multiDayMove], day)[0] : void 0;
|
|
2287
2797
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -2290,6 +2800,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2290
2800
|
onPointerMove: cellEnabled ? moveCreate : void 0,
|
|
2291
2801
|
onPointerUp: cellEnabled ? endCreate : void 0,
|
|
2292
2802
|
onPointerCancel: cellEnabled ? cancelCreate : void 0,
|
|
2803
|
+
onLostPointerCapture: cellEnabled ? loseCreateCapture : void 0,
|
|
2293
2804
|
onClick: cellEnabled ? (e) => tapCell(e, dayIndex) : void 0,
|
|
2294
2805
|
...dataState({
|
|
2295
2806
|
"data-today": (0, _super_calendar_core.getIsToday)(day),
|
|
@@ -2399,25 +2910,12 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2399
2910
|
ampm,
|
|
2400
2911
|
onPress
|
|
2401
2912
|
};
|
|
2402
|
-
const
|
|
2403
|
-
const canMove = editable && (pe.event.startEditable ?? eventStartEditable);
|
|
2404
|
-
const canResize = editable && (pe.event.durationEditable ?? eventDurationEditable);
|
|
2913
|
+
const { canMove, canResize } = editability(pe.event);
|
|
2405
2914
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2406
2915
|
role: "button",
|
|
2407
2916
|
tabIndex: 0,
|
|
2408
2917
|
"data-event-key": keyboardEventNavigation ? key : void 0,
|
|
2409
|
-
"aria-label":
|
|
2410
|
-
mode,
|
|
2411
|
-
isAllDay: false,
|
|
2412
|
-
ampm
|
|
2413
|
-
}) : (0, _super_calendar_core.eventAccessibilityLabel)({
|
|
2414
|
-
title: pe.event.title,
|
|
2415
|
-
isAllDay: false,
|
|
2416
|
-
start: pe.event.start,
|
|
2417
|
-
end: pe.event.end,
|
|
2418
|
-
ampm,
|
|
2419
|
-
labels
|
|
2420
|
-
}),
|
|
2918
|
+
"aria-label": eventLabel(pe.event),
|
|
2421
2919
|
onKeyDown: (e) => {
|
|
2422
2920
|
if (e.key === "Enter" || e.key === " ") {
|
|
2423
2921
|
e.preventDefault();
|
|
@@ -2559,15 +3057,17 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2559
3057
|
background: theme.nowIndicator
|
|
2560
3058
|
} })]
|
|
2561
3059
|
}) : null,
|
|
2562
|
-
ghost ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3060
|
+
ghost ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InertDiv, {
|
|
2563
3061
|
"aria-hidden": true,
|
|
3062
|
+
inert: !!ghostRange,
|
|
2564
3063
|
...slot("createGhost", {
|
|
2565
3064
|
base: {
|
|
2566
3065
|
position: "absolute",
|
|
2567
3066
|
left: eventGap,
|
|
2568
3067
|
right: eventGap,
|
|
2569
|
-
|
|
2570
|
-
|
|
3068
|
+
...createPreviewPlacement(Math.min(ghost.startPx, ghost.curPx), Math.abs(ghost.curPx - ghost.startPx), totalHeight),
|
|
3069
|
+
boxSizing: "border-box",
|
|
3070
|
+
...ghostRange ? { overflow: "hidden" } : null,
|
|
2571
3071
|
opacity: .7,
|
|
2572
3072
|
pointerEvents: "none",
|
|
2573
3073
|
zIndex: 2
|
|
@@ -2577,7 +3077,11 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2577
3077
|
border: `1px solid ${theme.selectedBackground}`,
|
|
2578
3078
|
borderRadius: 6
|
|
2579
3079
|
}
|
|
2580
|
-
})
|
|
3080
|
+
}),
|
|
3081
|
+
children: ghostRange && RenderCreateGhost ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderCreateGhost, {
|
|
3082
|
+
start: ghostRange.start,
|
|
3083
|
+
end: ghostRange.end
|
|
3084
|
+
}) : null
|
|
2581
3085
|
}) : null
|
|
2582
3086
|
]
|
|
2583
3087
|
}, day.toISOString());
|
|
@@ -2615,12 +3119,24 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2615
3119
|
theme,
|
|
2616
3120
|
boxProps: slot("eventBox")
|
|
2617
3121
|
})
|
|
3122
|
+
}) : null,
|
|
3123
|
+
openActionsEvent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EventActionsDialog, {
|
|
3124
|
+
dialogRef: eventActions.dialogRef,
|
|
3125
|
+
title: labels.eventActions(openActionsEvent.title ?? ""),
|
|
3126
|
+
description: eventDescription(openActionsEvent),
|
|
3127
|
+
actions: editActions(openActionsEvent),
|
|
3128
|
+
closeLabel: labels.close,
|
|
3129
|
+
rejectedLabel: labels.eventChangeRejected,
|
|
3130
|
+
rejections: eventActions.rejections,
|
|
3131
|
+
onAction: eventActions.run,
|
|
3132
|
+
onClose: () => eventActions.close(true),
|
|
3133
|
+
slot,
|
|
3134
|
+
theme
|
|
2618
3135
|
}) : null
|
|
2619
3136
|
]
|
|
2620
3137
|
});
|
|
2621
3138
|
}
|
|
2622
|
-
|
|
2623
|
-
//#region src/Calendar.tsx
|
|
3139
|
+
// src/Calendar.tsx
|
|
2624
3140
|
const EMPTY_EVENTS = [];
|
|
2625
3141
|
function expansionRange(mode, date, weekStartsOn, numberOfDays) {
|
|
2626
3142
|
if (mode === "month") return [(0, date_fns.startOfWeek)((0, date_fns.startOfMonth)(date), { weekStartsOn }), (0, date_fns.endOfWeek)((0, date_fns.endOfMonth)(date), { weekStartsOn })];
|
|
@@ -2647,7 +3163,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
2647
3163
|
* ```
|
|
2648
3164
|
*/
|
|
2649
3165
|
const Calendar = (0, react.forwardRef)(CalendarInner);
|
|
2650
|
-
function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, touchDragDelay, touchDragThreshold, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, chipHeight, chipGap, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }, ref) {
|
|
3166
|
+
function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, touchDragDelay, touchDragThreshold, onPressCell, onCreateEvent, renderCreateGhost, onDragStart, onDragEvent, getEventId, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, chipHeight, chipGap, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }, ref) {
|
|
2651
3167
|
const timeGridRef = (0, react.useRef)(null);
|
|
2652
3168
|
(0, react.useImperativeHandle)(ref, () => ({ scrollToTime: (minutes, options) => timeGridRef.current?.scrollToTime(minutes, options) }), []);
|
|
2653
3169
|
const displayEvents = (0, react.useMemo)(() => {
|
|
@@ -2805,8 +3321,10 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
2805
3321
|
onPressEvent,
|
|
2806
3322
|
onPressCell,
|
|
2807
3323
|
onCreateEvent,
|
|
3324
|
+
renderCreateGhost,
|
|
2808
3325
|
onDragStart,
|
|
2809
3326
|
onDragEvent,
|
|
3327
|
+
getEventId,
|
|
2810
3328
|
onChangeDate,
|
|
2811
3329
|
onPressDateHeader,
|
|
2812
3330
|
renderEvent: renderTimeEvent,
|
|
@@ -2820,8 +3338,7 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
2820
3338
|
children: view
|
|
2821
3339
|
});
|
|
2822
3340
|
}
|
|
2823
|
-
|
|
2824
|
-
//#region src/MonthList.tsx
|
|
3341
|
+
// src/MonthList.tsx
|
|
2825
3342
|
/**
|
|
2826
3343
|
* A vertically scrolling, virtualized list of months: the date picker. Built on
|
|
2827
3344
|
* Legend List's DOM renderer and the library's headless grid logic. Selection is
|
|
@@ -2858,18 +3375,61 @@ function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "s
|
|
|
2858
3375
|
for (const list of map.values()) list.sort(_super_calendar_core.compareDayEvents);
|
|
2859
3376
|
return map;
|
|
2860
3377
|
}, [events]);
|
|
2861
|
-
const
|
|
2862
|
-
|
|
2863
|
-
|
|
3378
|
+
const renderMonth = (0, react.useCallback)(({ item }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthView, {
|
|
3379
|
+
date: item,
|
|
3380
|
+
weekStartsOn,
|
|
3381
|
+
highlightWeekends,
|
|
2864
3382
|
events,
|
|
3383
|
+
eventsByDay,
|
|
3384
|
+
renderEvent,
|
|
3385
|
+
eventAccessibilityLabel,
|
|
3386
|
+
maxVisibleEventCount,
|
|
2865
3387
|
chipHeight,
|
|
2866
|
-
chipGap
|
|
2867
|
-
|
|
3388
|
+
chipGap,
|
|
3389
|
+
moreLabel,
|
|
3390
|
+
labels,
|
|
3391
|
+
onPressEvent,
|
|
3392
|
+
onPressMore,
|
|
2868
3393
|
selectedRange,
|
|
2869
3394
|
selectedDates,
|
|
3395
|
+
fillCellOnSelection,
|
|
3396
|
+
showAdjacentMonths: false,
|
|
3397
|
+
showWeekdays: false,
|
|
3398
|
+
locale,
|
|
3399
|
+
theme: themeOverrides,
|
|
3400
|
+
minDate,
|
|
3401
|
+
maxDate,
|
|
3402
|
+
isDateDisabled,
|
|
3403
|
+
keyboardDayNavigation,
|
|
3404
|
+
onPressDay,
|
|
3405
|
+
classNames,
|
|
3406
|
+
styles
|
|
3407
|
+
}), [
|
|
3408
|
+
weekStartsOn,
|
|
3409
|
+
highlightWeekends,
|
|
2870
3410
|
events,
|
|
3411
|
+
eventsByDay,
|
|
3412
|
+
renderEvent,
|
|
3413
|
+
eventAccessibilityLabel,
|
|
3414
|
+
maxVisibleEventCount,
|
|
2871
3415
|
chipHeight,
|
|
2872
|
-
chipGap
|
|
3416
|
+
chipGap,
|
|
3417
|
+
moreLabel,
|
|
3418
|
+
labels,
|
|
3419
|
+
onPressEvent,
|
|
3420
|
+
onPressMore,
|
|
3421
|
+
selectedRange,
|
|
3422
|
+
selectedDates,
|
|
3423
|
+
fillCellOnSelection,
|
|
3424
|
+
locale,
|
|
3425
|
+
themeOverrides,
|
|
3426
|
+
minDate,
|
|
3427
|
+
maxDate,
|
|
3428
|
+
isDateDisabled,
|
|
3429
|
+
keyboardDayNavigation,
|
|
3430
|
+
onPressDay,
|
|
3431
|
+
classNames,
|
|
3432
|
+
styles
|
|
2873
3433
|
]);
|
|
2874
3434
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2875
3435
|
className,
|
|
@@ -2900,7 +3460,7 @@ function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "s
|
|
|
2900
3460
|
}, wd.label))
|
|
2901
3461
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_legendapp_list_react.LegendList, {
|
|
2902
3462
|
data: months,
|
|
2903
|
-
extraData,
|
|
3463
|
+
extraData: renderMonth,
|
|
2904
3464
|
keyExtractor: (m) => m.toISOString(),
|
|
2905
3465
|
recycleItems: false,
|
|
2906
3466
|
estimatedItemSize: theme.cellHeight * 7 + 40,
|
|
@@ -2909,41 +3469,11 @@ function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "s
|
|
|
2909
3469
|
height,
|
|
2910
3470
|
overflowY: "auto"
|
|
2911
3471
|
},
|
|
2912
|
-
renderItem:
|
|
2913
|
-
date: item,
|
|
2914
|
-
weekStartsOn,
|
|
2915
|
-
highlightWeekends,
|
|
2916
|
-
events,
|
|
2917
|
-
eventsByDay,
|
|
2918
|
-
renderEvent,
|
|
2919
|
-
eventAccessibilityLabel,
|
|
2920
|
-
maxVisibleEventCount,
|
|
2921
|
-
chipHeight,
|
|
2922
|
-
chipGap,
|
|
2923
|
-
moreLabel,
|
|
2924
|
-
labels,
|
|
2925
|
-
onPressEvent,
|
|
2926
|
-
onPressMore,
|
|
2927
|
-
selectedRange,
|
|
2928
|
-
selectedDates,
|
|
2929
|
-
fillCellOnSelection,
|
|
2930
|
-
showAdjacentMonths: false,
|
|
2931
|
-
showWeekdays: false,
|
|
2932
|
-
locale,
|
|
2933
|
-
theme: themeOverrides,
|
|
2934
|
-
minDate,
|
|
2935
|
-
maxDate,
|
|
2936
|
-
isDateDisabled,
|
|
2937
|
-
keyboardDayNavigation,
|
|
2938
|
-
onPressDay,
|
|
2939
|
-
classNames,
|
|
2940
|
-
styles
|
|
2941
|
-
})
|
|
3472
|
+
renderItem: renderMonth
|
|
2942
3473
|
})]
|
|
2943
3474
|
});
|
|
2944
3475
|
}
|
|
2945
|
-
|
|
2946
|
-
//#region src/DateRangePicker.tsx
|
|
3476
|
+
// src/DateRangePicker.tsx
|
|
2947
3477
|
const triggerDefault = {
|
|
2948
3478
|
display: "inline-flex",
|
|
2949
3479
|
alignItems: "center",
|
|
@@ -2964,17 +3494,25 @@ const popoverDefault = {
|
|
|
2964
3494
|
borderRadius: 12,
|
|
2965
3495
|
minWidth: 300
|
|
2966
3496
|
};
|
|
3497
|
+
function initialPickerFocus(dialog, day) {
|
|
3498
|
+
const usable = ":not([aria-disabled=\"true\"]):not([data-outside])";
|
|
3499
|
+
return dialog.querySelector(`[data-day="${day}"]${usable}`) ?? dialog.querySelector(`[data-day^="${day.slice(0, 7)}"][tabindex="0"]${usable}`) ?? dialog.querySelector(`[data-day^="${day.slice(0, 7)}"]${usable}`);
|
|
3500
|
+
}
|
|
2967
3501
|
/**
|
|
2968
3502
|
* The shared popover shell: a trigger button and a calendar panel that closes on
|
|
2969
3503
|
* outside-click and Escape, and returns focus to the trigger. `renderCalendar`
|
|
2970
3504
|
* gets a close callback so a single-date pick can dismiss immediately.
|
|
2971
3505
|
*/
|
|
2972
|
-
function usePopover() {
|
|
3506
|
+
function usePopover(disabled) {
|
|
2973
3507
|
const [open, setOpen] = (0, react.useState)(false);
|
|
2974
3508
|
const rootRef = (0, react.useRef)(null);
|
|
2975
3509
|
const triggerRef = (0, react.useRef)(null);
|
|
2976
3510
|
(0, react.useEffect)(() => {
|
|
2977
3511
|
if (!open) return;
|
|
3512
|
+
if (disabled) {
|
|
3513
|
+
setOpen(false);
|
|
3514
|
+
return;
|
|
3515
|
+
}
|
|
2978
3516
|
const onDown = (e) => {
|
|
2979
3517
|
if (!rootRef.current?.contains(e.target)) setOpen(false);
|
|
2980
3518
|
};
|
|
@@ -2990,16 +3528,43 @@ function usePopover() {
|
|
|
2990
3528
|
document.removeEventListener("mousedown", onDown);
|
|
2991
3529
|
document.removeEventListener("keydown", onKey);
|
|
2992
3530
|
};
|
|
2993
|
-
}, [open]);
|
|
3531
|
+
}, [open, disabled]);
|
|
2994
3532
|
return {
|
|
2995
|
-
open,
|
|
3533
|
+
open: open && !disabled,
|
|
2996
3534
|
setOpen,
|
|
2997
3535
|
rootRef,
|
|
2998
3536
|
triggerRef
|
|
2999
3537
|
};
|
|
3000
3538
|
}
|
|
3001
|
-
function PickerShell({ open, setOpen, rootRef, triggerRef, theme, slot, label, hasValue, placeholder, disabled, className, style, ariaLabel, children }) {
|
|
3539
|
+
function PickerShell({ open, setOpen, rootRef, triggerRef, theme, slot, label, hasValue, placeholder, disabled, className, style, ariaLabel, focusDay, children }) {
|
|
3002
3540
|
const dialogId = (0, react.useId)();
|
|
3541
|
+
const dialogRef = (0, react.useRef)(null);
|
|
3542
|
+
const focusDayRef = (0, react.useRef)(focusDay);
|
|
3543
|
+
focusDayRef.current = focusDay;
|
|
3544
|
+
(0, react.useEffect)(() => {
|
|
3545
|
+
if (!open) return;
|
|
3546
|
+
const dialog = dialogRef.current;
|
|
3547
|
+
if (!dialog) return;
|
|
3548
|
+
const place = () => {
|
|
3549
|
+
if (dialog.contains(document.activeElement)) {
|
|
3550
|
+
observer.disconnect();
|
|
3551
|
+
return;
|
|
3552
|
+
}
|
|
3553
|
+
const target = initialPickerFocus(dialog, focusDayRef.current);
|
|
3554
|
+
const monthMounted = dialog.querySelector(`[data-day^="${focusDayRef.current.slice(0, 7)}"]:not([data-outside])`);
|
|
3555
|
+
if (target || monthMounted) {
|
|
3556
|
+
(target ?? dialog).focus();
|
|
3557
|
+
observer.disconnect();
|
|
3558
|
+
}
|
|
3559
|
+
};
|
|
3560
|
+
const observer = new MutationObserver(place);
|
|
3561
|
+
observer.observe(dialog, {
|
|
3562
|
+
childList: true,
|
|
3563
|
+
subtree: true
|
|
3564
|
+
});
|
|
3565
|
+
place();
|
|
3566
|
+
return () => observer.disconnect();
|
|
3567
|
+
}, [open]);
|
|
3003
3568
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3004
3569
|
ref: rootRef,
|
|
3005
3570
|
className,
|
|
@@ -3031,8 +3596,10 @@ function PickerShell({ open, setOpen, rootRef, triggerRef, theme, slot, label, h
|
|
|
3031
3596
|
children: "▾"
|
|
3032
3597
|
})]
|
|
3033
3598
|
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3599
|
+
ref: dialogRef,
|
|
3034
3600
|
id: dialogId,
|
|
3035
3601
|
role: "dialog",
|
|
3602
|
+
tabIndex: -1,
|
|
3036
3603
|
"aria-label": ariaLabel,
|
|
3037
3604
|
...slot("popover", {
|
|
3038
3605
|
base: popoverDefault,
|
|
@@ -3062,7 +3629,7 @@ function DatePicker({ value, onChange, formatLabel = (d) => (0, date_fns.format)
|
|
|
3062
3629
|
classNames,
|
|
3063
3630
|
styles
|
|
3064
3631
|
});
|
|
3065
|
-
const { open, setOpen, rootRef, triggerRef } = usePopover();
|
|
3632
|
+
const { open, setOpen, rootRef, triggerRef } = usePopover(disabled);
|
|
3066
3633
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PickerShell, {
|
|
3067
3634
|
open,
|
|
3068
3635
|
setOpen,
|
|
@@ -3077,7 +3644,9 @@ function DatePicker({ value, onChange, formatLabel = (d) => (0, date_fns.format)
|
|
|
3077
3644
|
className,
|
|
3078
3645
|
style,
|
|
3079
3646
|
ariaLabel: "Choose a date",
|
|
3647
|
+
focusDay: (0, date_fns.format)(value ?? /* @__PURE__ */ new Date(), "yyyy-MM-dd"),
|
|
3080
3648
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthList, {
|
|
3649
|
+
theme: themeOverrides,
|
|
3081
3650
|
date: value ?? /* @__PURE__ */ new Date(),
|
|
3082
3651
|
weekStartsOn,
|
|
3083
3652
|
selectedDates: value ? [value] : [],
|
|
@@ -3116,7 +3685,7 @@ function DateRangePicker({ value, onChange, formatLabel = defaultRangeLabel, wee
|
|
|
3116
3685
|
classNames,
|
|
3117
3686
|
styles
|
|
3118
3687
|
});
|
|
3119
|
-
const { open, setOpen, rootRef, triggerRef } = usePopover();
|
|
3688
|
+
const { open, setOpen, rootRef, triggerRef } = usePopover(disabled);
|
|
3120
3689
|
const constraints = {
|
|
3121
3690
|
minDate,
|
|
3122
3691
|
maxDate,
|
|
@@ -3136,7 +3705,9 @@ function DateRangePicker({ value, onChange, formatLabel = defaultRangeLabel, wee
|
|
|
3136
3705
|
className,
|
|
3137
3706
|
style,
|
|
3138
3707
|
ariaLabel: "Choose a date range",
|
|
3708
|
+
focusDay: (0, date_fns.format)(value?.start ?? /* @__PURE__ */ new Date(), "yyyy-MM-dd"),
|
|
3139
3709
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthList, {
|
|
3710
|
+
theme: themeOverrides,
|
|
3140
3711
|
date: value?.start ?? /* @__PURE__ */ new Date(),
|
|
3141
3712
|
weekStartsOn,
|
|
3142
3713
|
selectedRange: value ?? void 0,
|
|
@@ -3180,8 +3751,7 @@ function DateRangePicker({ value, onChange, formatLabel = defaultRangeLabel, wee
|
|
|
3180
3751
|
})]
|
|
3181
3752
|
});
|
|
3182
3753
|
}
|
|
3183
|
-
|
|
3184
|
-
//#region src/ResourceTimeline.tsx
|
|
3754
|
+
// src/ResourceTimeline.tsx
|
|
3185
3755
|
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
3186
3756
|
const GUTTER_WIDTH = 56;
|
|
3187
3757
|
function DefaultBar({ event, height, boxProps, theme }) {
|
|
@@ -3250,7 +3820,7 @@ function DefaultBar({ event, height, boxProps, theme }) {
|
|
|
3250
3820
|
* />
|
|
3251
3821
|
* ```
|
|
3252
3822
|
*/
|
|
3253
|
-
function ResourceTimeline({ date, orientation = "horizontal", resources: allResources, resourcesPerPage, resourcePage = 0, 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, renderBusinessHours, renderResourceHeader, dragStepMinutes = 15, showNowIndicator = true, now: nowProp, timeZone, className, style, classNames, styles }) {
|
|
3823
|
+
function ResourceTimeline({ date, orientation = "horizontal", resources: allResources, resourcesPerPage, resourcePage = 0, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, theme: themeOverrides, renderEvent, onPressEvent, onDragEvent, getEventId, onPressCell, onCreateEvent, renderCreateGhost, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes = 15, labels: labelsProp, showNowIndicator = true, now: nowProp, timeZone, className, style, classNames, styles }) {
|
|
3254
3824
|
const resources = (0, react.useMemo)(() => {
|
|
3255
3825
|
if (!resourcesPerPage || resourcesPerPage <= 0) return allResources;
|
|
3256
3826
|
const pages = Math.max(1, Math.ceil(allResources.length / resourcesPerPage));
|
|
@@ -3262,6 +3832,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3262
3832
|
resourcePage
|
|
3263
3833
|
]);
|
|
3264
3834
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
3835
|
+
const labels = (0, react.useMemo)(() => (0, _super_calendar_core.resolveCalendarLabels)(labelsProp), [labelsProp]);
|
|
3265
3836
|
const slot = createSlots({
|
|
3266
3837
|
classNames,
|
|
3267
3838
|
styles
|
|
@@ -3301,19 +3872,33 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3301
3872
|
}, `now-${resourceKey}`) : null;
|
|
3302
3873
|
const [drag, setDrag] = (0, react.useState)(null);
|
|
3303
3874
|
const dragRef = (0, react.useRef)(null);
|
|
3875
|
+
const handledClick = (0, react.useRef)(null);
|
|
3304
3876
|
const origin = (0, react.useRef)(null);
|
|
3305
3877
|
const applyDrag = (next) => {
|
|
3306
3878
|
dragRef.current = next;
|
|
3307
3879
|
setDrag(next);
|
|
3308
3880
|
};
|
|
3309
|
-
const
|
|
3881
|
+
const clearDrag = () => {
|
|
3882
|
+
const previous = dragRef.current;
|
|
3883
|
+
const element = origin.current?.element;
|
|
3884
|
+
applyDrag(null);
|
|
3885
|
+
origin.current = null;
|
|
3886
|
+
try {
|
|
3887
|
+
if (previous) element?.releasePointerCapture?.(previous.pointerId);
|
|
3888
|
+
} catch {}
|
|
3889
|
+
};
|
|
3890
|
+
const beginDrag = (e, resource, kind, pe) => {
|
|
3310
3891
|
const { startHours, durationHours } = pe;
|
|
3311
|
-
if (!
|
|
3892
|
+
if (e.button === 0 && e.isPrimary !== false && !dragRef.current) handledClick.current = null;
|
|
3893
|
+
if (!onDragEvent || pe.event.draggable === false || dragRef.current || createOrigin.current || e.isPrimary === false || e.button !== 0) return;
|
|
3894
|
+
const element = e.currentTarget.closest("button");
|
|
3895
|
+
if (!element) return;
|
|
3312
3896
|
e.stopPropagation();
|
|
3313
3897
|
try {
|
|
3314
|
-
|
|
3898
|
+
element.setPointerCapture?.(e.pointerId);
|
|
3315
3899
|
} catch {}
|
|
3316
3900
|
origin.current = {
|
|
3901
|
+
element,
|
|
3317
3902
|
x: vertical ? e.clientY : e.clientX,
|
|
3318
3903
|
cross: vertical ? e.clientX : e.clientY,
|
|
3319
3904
|
startHours,
|
|
@@ -3324,8 +3909,9 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3324
3909
|
}
|
|
3325
3910
|
};
|
|
3326
3911
|
applyDrag({
|
|
3327
|
-
|
|
3328
|
-
|
|
3912
|
+
pointerId: e.pointerId,
|
|
3913
|
+
event: pe.event,
|
|
3914
|
+
resource,
|
|
3329
3915
|
kind,
|
|
3330
3916
|
startHours,
|
|
3331
3917
|
durationHours,
|
|
@@ -3335,7 +3921,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3335
3921
|
};
|
|
3336
3922
|
const moveDrag = (e) => {
|
|
3337
3923
|
const d = dragRef.current;
|
|
3338
|
-
if (!d || !origin.current) return;
|
|
3924
|
+
if (!d || d.pointerId !== e.pointerId || !origin.current) return;
|
|
3339
3925
|
const dHours = ((vertical ? e.clientY : e.clientX) - origin.current.x) / hourSize;
|
|
3340
3926
|
const snap = (v) => Math.round(v / snapHours) * snapHours;
|
|
3341
3927
|
if (d.kind === "move") {
|
|
@@ -3376,39 +3962,76 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3376
3962
|
const id = (hit?.closest?.("[data-resource-id]"))?.getAttribute("data-resource-id");
|
|
3377
3963
|
return id && resources.find((r) => r.id === id) || fallback;
|
|
3378
3964
|
};
|
|
3379
|
-
const endDrag = (e
|
|
3965
|
+
const endDrag = (e) => {
|
|
3380
3966
|
const d = dragRef.current;
|
|
3381
|
-
if (!d) return;
|
|
3382
|
-
|
|
3383
|
-
e.target.releasePointerCapture?.(e.pointerId);
|
|
3384
|
-
} catch {}
|
|
3967
|
+
if (!d || d.pointerId !== e.pointerId) return;
|
|
3968
|
+
handledClick.current = origin.current?.element ?? null;
|
|
3385
3969
|
if (!d.moved) {
|
|
3386
|
-
|
|
3387
|
-
|
|
3970
|
+
clearDrag();
|
|
3971
|
+
onPressEvent?.(d.event);
|
|
3972
|
+
return;
|
|
3973
|
+
}
|
|
3974
|
+
const resource = resources.find((resource) => resource.id === d.resource.id);
|
|
3975
|
+
if (!resource) {
|
|
3976
|
+
clearDrag();
|
|
3388
3977
|
return;
|
|
3389
3978
|
}
|
|
3390
3979
|
const target = d.kind === "move" ? laneAt(e, resource) : resource;
|
|
3391
3980
|
const o = origin.current;
|
|
3392
3981
|
const startDelta = o ? Math.round((d.startHours - o.startHours) * 60) : 0;
|
|
3393
3982
|
const endDelta = d.kind === "move" ? startDelta : o ? Math.round((d.durationHours - o.durationHours) * 60) : 0;
|
|
3394
|
-
const next = (0, _super_calendar_core.resolveDraggedBounds)(event.start, event.end, startDelta, endDelta, dragStepMinutes);
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
origin.current = null;
|
|
3983
|
+
const next = (0, _super_calendar_core.resolveDraggedBounds)(d.event.start, d.event.end, startDelta, endDelta, dragStepMinutes);
|
|
3984
|
+
clearDrag();
|
|
3985
|
+
if (next) onDragEvent?.(d.event, next.start, next.end, target);
|
|
3398
3986
|
};
|
|
3399
|
-
const cancelDrag = () => {
|
|
3400
|
-
|
|
3401
|
-
|
|
3987
|
+
const cancelDrag = (e) => {
|
|
3988
|
+
if (dragRef.current?.pointerId !== e.pointerId) return;
|
|
3989
|
+
handledClick.current = origin.current?.element ?? null;
|
|
3990
|
+
clearDrag();
|
|
3402
3991
|
};
|
|
3403
3992
|
const [createBox, setCreateBox] = (0, react.useState)(null);
|
|
3404
3993
|
const createOrigin = (0, react.useRef)(null);
|
|
3994
|
+
const createActive = createBox !== null;
|
|
3995
|
+
(0, react.useEffect)(() => {
|
|
3996
|
+
if (!createActive) return;
|
|
3997
|
+
const onScroll = () => {
|
|
3998
|
+
const origin = createOrigin.current;
|
|
3999
|
+
if (!origin) return;
|
|
4000
|
+
const rect = origin.el.getBoundingClientRect();
|
|
4001
|
+
const curPx = vertical ? origin.clientY - rect.top : origin.clientX - rect.left;
|
|
4002
|
+
setCreateBox((current) => current && current.curPx !== curPx ? {
|
|
4003
|
+
...current,
|
|
4004
|
+
curPx
|
|
4005
|
+
} : current);
|
|
4006
|
+
};
|
|
4007
|
+
window.addEventListener("scroll", onScroll, true);
|
|
4008
|
+
return () => window.removeEventListener("scroll", onScroll, true);
|
|
4009
|
+
}, [createActive, vertical]);
|
|
4010
|
+
const clearCreate = (0, react.useCallback)(() => {
|
|
4011
|
+
const previous = createOrigin.current;
|
|
4012
|
+
createOrigin.current = null;
|
|
4013
|
+
setCreateBox(null);
|
|
4014
|
+
try {
|
|
4015
|
+
previous?.el.releasePointerCapture?.(previous.pointerId);
|
|
4016
|
+
} catch {}
|
|
4017
|
+
}, []);
|
|
4018
|
+
(0, react.useEffect)(() => {
|
|
4019
|
+
const onKeyDown = (event) => {
|
|
4020
|
+
if (event.key !== "Escape" || !createOrigin.current) return;
|
|
4021
|
+
event.preventDefault();
|
|
4022
|
+
event.stopPropagation();
|
|
4023
|
+
clearCreate();
|
|
4024
|
+
};
|
|
4025
|
+
document.addEventListener("keydown", onKeyDown);
|
|
4026
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
4027
|
+
}, [clearCreate]);
|
|
3405
4028
|
const cellEnabled = !!onPressCell || !!onCreateEvent;
|
|
3406
4029
|
const pxAlongAxis = (el, e) => {
|
|
3407
4030
|
const rect = el.getBoundingClientRect();
|
|
3408
4031
|
return vertical ? e.clientY - rect.top : e.clientX - rect.left;
|
|
3409
4032
|
};
|
|
3410
4033
|
const beginCreate = (e, resource) => {
|
|
3411
|
-
if (!cellEnabled || e.pointerType === "touch") return;
|
|
4034
|
+
if (!cellEnabled || e.pointerType === "touch" || e.isPrimary === false || createOrigin.current || dragRef.current) return;
|
|
3412
4035
|
if (e.target !== e.currentTarget || e.button > 0) return;
|
|
3413
4036
|
const el = e.currentTarget;
|
|
3414
4037
|
const startPx = pxAlongAxis(el, e);
|
|
@@ -3416,9 +4039,14 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3416
4039
|
el.setPointerCapture?.(e.pointerId);
|
|
3417
4040
|
} catch {}
|
|
3418
4041
|
createOrigin.current = {
|
|
4042
|
+
pointerId: e.pointerId,
|
|
4043
|
+
clientX: e.clientX,
|
|
4044
|
+
clientY: e.clientY,
|
|
3419
4045
|
el,
|
|
3420
4046
|
resource,
|
|
3421
|
-
startPx
|
|
4047
|
+
startPx,
|
|
4048
|
+
dayKey: date.toDateString(),
|
|
4049
|
+
creating: !!onCreateEvent
|
|
3422
4050
|
};
|
|
3423
4051
|
if (onCreateEvent) setCreateBox({
|
|
3424
4052
|
resourceKey: resource.id,
|
|
@@ -3428,7 +4056,9 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3428
4056
|
};
|
|
3429
4057
|
const moveCreate = (e) => {
|
|
3430
4058
|
const o = createOrigin.current;
|
|
3431
|
-
if (!o || !onCreateEvent) return;
|
|
4059
|
+
if (!o || o.pointerId !== e.pointerId || !onCreateEvent) return;
|
|
4060
|
+
o.clientX = e.clientX;
|
|
4061
|
+
o.clientY = e.clientY;
|
|
3432
4062
|
setCreateBox({
|
|
3433
4063
|
resourceKey: o.resource.id,
|
|
3434
4064
|
startPx: o.startPx,
|
|
@@ -3437,31 +4067,155 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3437
4067
|
};
|
|
3438
4068
|
const endCreate = (e) => {
|
|
3439
4069
|
const o = createOrigin.current;
|
|
3440
|
-
if (!o) return;
|
|
3441
|
-
try {
|
|
3442
|
-
o.el.releasePointerCapture?.(e.pointerId);
|
|
3443
|
-
} catch {}
|
|
4070
|
+
if (!o || o.pointerId !== e.pointerId) return;
|
|
3444
4071
|
const endPx = pxAlongAxis(o.el, e);
|
|
3445
|
-
|
|
4072
|
+
const moved = Math.abs(endPx - o.startPx) > 4;
|
|
4073
|
+
clearCreate();
|
|
4074
|
+
const resource = resources.find((resource) => resource.id === o.resource.id);
|
|
4075
|
+
if (!resource) return;
|
|
4076
|
+
if (moved && onCreateEvent) {
|
|
3446
4077
|
const range = (0, _super_calendar_core.cellRangeFromDrag)(date, o.startPx, endPx, hourSize, startHour, dragStepMinutes);
|
|
3447
|
-
if (range) onCreateEvent(range.start, range.end,
|
|
4078
|
+
if (range) onCreateEvent(range.start, range.end, resource);
|
|
3448
4079
|
} else if (onPressCell) {
|
|
3449
4080
|
const at = (0, _super_calendar_core.cellRangeFromDrag)(date, o.startPx, o.startPx, hourSize, startHour, dragStepMinutes);
|
|
3450
|
-
if (at) onPressCell(at.start,
|
|
4081
|
+
if (at) onPressCell(at.start, resource);
|
|
3451
4082
|
}
|
|
3452
|
-
createOrigin.current = null;
|
|
3453
|
-
setCreateBox(null);
|
|
3454
4083
|
};
|
|
3455
|
-
const cancelCreate = () => {
|
|
3456
|
-
createOrigin.current
|
|
3457
|
-
|
|
4084
|
+
const cancelCreate = (e) => {
|
|
4085
|
+
if (createOrigin.current?.pointerId !== e.pointerId) return;
|
|
4086
|
+
clearCreate();
|
|
3458
4087
|
};
|
|
3459
|
-
const
|
|
4088
|
+
const RenderCreateGhost = renderCreateGhost;
|
|
4089
|
+
const liveRange = createBox && RenderCreateGhost && onCreateEvent ? (0, _super_calendar_core.cellRangeFromDrag)(date, createBox.startPx, createBox.curPx, hourSize, startHour, dragStepMinutes) : null;
|
|
4090
|
+
const liveStart = liveRange?.start.getTime();
|
|
4091
|
+
const liveEnd = liveRange?.end.getTime();
|
|
4092
|
+
const createRange = (0, react.useMemo)(() => liveStart === void 0 || liveEnd === void 0 ? null : {
|
|
4093
|
+
start: new Date(liveStart),
|
|
4094
|
+
end: new Date(liveEnd)
|
|
4095
|
+
}, [liveStart, liveEnd]);
|
|
4096
|
+
const trackInteractionProps = (resource) => ({
|
|
3460
4097
|
onPointerDown: (e) => beginCreate(e, resource),
|
|
3461
4098
|
onPointerMove: moveCreate,
|
|
3462
4099
|
onPointerUp: endCreate,
|
|
3463
|
-
onPointerCancel: cancelCreate
|
|
3464
|
-
|
|
4100
|
+
onPointerCancel: cancelCreate,
|
|
4101
|
+
onLostPointerCapture: cancelCreate
|
|
4102
|
+
});
|
|
4103
|
+
(0, react.useEffect)(() => {
|
|
4104
|
+
if (dragRef.current && (!origin.current?.element.isConnected || !events.includes(dragRef.current.event))) clearDrag();
|
|
4105
|
+
const creating = createOrigin.current;
|
|
4106
|
+
if (creating && (!creating.el.isConnected || !cellEnabled || creating.creating && !onCreateEvent || creating.dayKey !== date.toDateString())) clearCreate();
|
|
4107
|
+
});
|
|
4108
|
+
(0, react.useEffect)(() => () => {
|
|
4109
|
+
const captured = origin.current;
|
|
4110
|
+
const currentDrag = dragRef.current;
|
|
4111
|
+
const currentCreate = createOrigin.current;
|
|
4112
|
+
origin.current = null;
|
|
4113
|
+
dragRef.current = null;
|
|
4114
|
+
createOrigin.current = null;
|
|
4115
|
+
try {
|
|
4116
|
+
if (currentDrag) captured?.element.releasePointerCapture?.(currentDrag.pointerId);
|
|
4117
|
+
currentCreate?.el.releasePointerCapture?.(currentCreate.pointerId);
|
|
4118
|
+
} catch {}
|
|
4119
|
+
}, []);
|
|
4120
|
+
const eventKeys = (0, react.useRef)(/* @__PURE__ */ new WeakMap());
|
|
4121
|
+
const nextEventKey = (0, react.useRef)(0);
|
|
4122
|
+
const eventKey = (event) => {
|
|
4123
|
+
let key = eventKeys.current.get(event);
|
|
4124
|
+
if (key === void 0) {
|
|
4125
|
+
key = nextEventKey.current++;
|
|
4126
|
+
eventKeys.current.set(event, key);
|
|
4127
|
+
}
|
|
4128
|
+
return key;
|
|
4129
|
+
};
|
|
4130
|
+
const laneOf = (event) => resources.findIndex((resource) => resource.id === resourceId(event));
|
|
4131
|
+
const eventDescription = (event) => `${resources.find((resource) => resource.id === resourceId(event))?.title ?? ""}, ${describeEventDates(event)}, ${(0, _super_calendar_core.eventAccessibilityLabel)({
|
|
4132
|
+
title: event.title,
|
|
4133
|
+
isAllDay: false,
|
|
4134
|
+
start: event.start,
|
|
4135
|
+
end: event.end,
|
|
4136
|
+
ampm,
|
|
4137
|
+
labels
|
|
4138
|
+
})}`;
|
|
4139
|
+
const actionDelta = (id) => {
|
|
4140
|
+
switch (id) {
|
|
4141
|
+
case "move-later": return [
|
|
4142
|
+
dragStepMinutes,
|
|
4143
|
+
dragStepMinutes,
|
|
4144
|
+
0
|
|
4145
|
+
];
|
|
4146
|
+
case "move-earlier": return [
|
|
4147
|
+
-dragStepMinutes,
|
|
4148
|
+
-dragStepMinutes,
|
|
4149
|
+
0
|
|
4150
|
+
];
|
|
4151
|
+
case "extend": return [
|
|
4152
|
+
0,
|
|
4153
|
+
dragStepMinutes,
|
|
4154
|
+
0
|
|
4155
|
+
];
|
|
4156
|
+
case "shorten": return [
|
|
4157
|
+
0,
|
|
4158
|
+
-dragStepMinutes,
|
|
4159
|
+
0
|
|
4160
|
+
];
|
|
4161
|
+
case "move-next-resource": return [
|
|
4162
|
+
0,
|
|
4163
|
+
0,
|
|
4164
|
+
1
|
|
4165
|
+
];
|
|
4166
|
+
case "move-previous-resource": return [
|
|
4167
|
+
0,
|
|
4168
|
+
0,
|
|
4169
|
+
-1
|
|
4170
|
+
];
|
|
4171
|
+
default: return null;
|
|
4172
|
+
}
|
|
4173
|
+
};
|
|
4174
|
+
const editActions = (event) => {
|
|
4175
|
+
if ((0, _super_calendar_core.isAllDayEvent)(event) || (0, _super_calendar_core.isBackgroundEvent)(event)) return [];
|
|
4176
|
+
const lane = laneOf(event);
|
|
4177
|
+
if (!onDragEvent || event.draggable === false || lane < 0) return [];
|
|
4178
|
+
const action = (id, label) => {
|
|
4179
|
+
const [startDelta, endDelta] = actionDelta(id) ?? [0, 0];
|
|
4180
|
+
return {
|
|
4181
|
+
id,
|
|
4182
|
+
label,
|
|
4183
|
+
available: (0, _super_calendar_core.resolveDraggedBounds)(event.start, event.end, startDelta, endDelta, dragStepMinutes) !== null
|
|
4184
|
+
};
|
|
4185
|
+
};
|
|
4186
|
+
const laneTitle = (resource) => resource && (resource.title || resource.id);
|
|
4187
|
+
const nextLane = laneTitle(resources[lane + 1]);
|
|
4188
|
+
const previousLane = laneTitle(resources[lane - 1]);
|
|
4189
|
+
return [
|
|
4190
|
+
action("move-later", labels.moveLater(dragStepMinutes)),
|
|
4191
|
+
action("move-earlier", labels.moveEarlier(dragStepMinutes)),
|
|
4192
|
+
action("extend", labels.extend(dragStepMinutes)),
|
|
4193
|
+
action("shorten", labels.shorten(dragStepMinutes)),
|
|
4194
|
+
...nextLane ? [action("move-next-resource", labels.moveToResource(nextLane))] : [],
|
|
4195
|
+
...previousLane ? [action("move-previous-resource", labels.moveToResource(previousLane))] : []
|
|
4196
|
+
];
|
|
4197
|
+
};
|
|
4198
|
+
const eventActions = useEventActions(events, editActions, (event, id) => {
|
|
4199
|
+
const delta = actionDelta(id);
|
|
4200
|
+
const target = delta ? resources[laneOf(event) + delta[2]] : void 0;
|
|
4201
|
+
const next = delta && target && (0, _super_calendar_core.resolveDraggedBounds)(event.start, event.end, delta[0], delta[1], dragStepMinutes);
|
|
4202
|
+
if (!next || !target || onDragEvent?.(event, next.start, next.end, target) === false) return null;
|
|
4203
|
+
return (candidate) => candidate !== event && candidate.start.getTime() === next.start.getTime() && candidate.end.getTime() === next.end.getTime() && candidate.title === event.title && resourceId(candidate) === target.id;
|
|
4204
|
+
}, getEventId);
|
|
4205
|
+
const openActionsEvent = eventActions.openEvent;
|
|
4206
|
+
const actionsDialog = openActionsEvent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EventActionsDialog, {
|
|
4207
|
+
dialogRef: eventActions.dialogRef,
|
|
4208
|
+
title: labels.eventActions(openActionsEvent.title ?? ""),
|
|
4209
|
+
description: eventDescription(openActionsEvent),
|
|
4210
|
+
actions: editActions(openActionsEvent),
|
|
4211
|
+
closeLabel: labels.close,
|
|
4212
|
+
rejectedLabel: labels.eventChangeRejected,
|
|
4213
|
+
rejections: eventActions.rejections,
|
|
4214
|
+
onAction: eventActions.run,
|
|
4215
|
+
onClose: () => eventActions.close(true),
|
|
4216
|
+
slot,
|
|
4217
|
+
theme
|
|
4218
|
+
}) : null;
|
|
3465
4219
|
const bandsFor = (resource) => businessHours ? (0, _super_calendar_core.closedHourBands)(date, (d) => businessHours(d, resource), startHour, endHour) : [];
|
|
3466
4220
|
const backgroundBandsFor = (resource) => (0, _super_calendar_core.backgroundBandsForDay)(events.filter((e) => resourceId(e) === resource.id), date).map((b) => ({
|
|
3467
4221
|
...b,
|
|
@@ -3483,11 +4237,13 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3483
4237
|
resourceId,
|
|
3484
4238
|
date
|
|
3485
4239
|
]);
|
|
3486
|
-
const dragLaneId = drag?.kind === "move" && drag.moved ? drag.
|
|
4240
|
+
const dragLaneId = drag?.kind === "move" && drag.moved ? drag.resource.id : null;
|
|
3487
4241
|
if (vertical) {
|
|
3488
4242
|
const trackHeight = (endHour - startHour) * hourHeight;
|
|
3489
4243
|
const vGridLines = `repeating-linear-gradient(to bottom, transparent 0, transparent ${hourHeight - 1}px, ${theme.gridLine} ${hourHeight - 1}px, ${theme.gridLine} ${hourHeight}px)`;
|
|
3490
4244
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4245
|
+
ref: eventActions.rootRef,
|
|
4246
|
+
tabIndex: -1,
|
|
3491
4247
|
className,
|
|
3492
4248
|
style: {
|
|
3493
4249
|
fontFamily: theme.fontFamily,
|
|
@@ -3495,85 +4251,347 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3495
4251
|
overflowY: "auto",
|
|
3496
4252
|
...style
|
|
3497
4253
|
},
|
|
3498
|
-
children: [
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
background: theme.surface
|
|
3509
|
-
}
|
|
4254
|
+
children: [
|
|
4255
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EventActionsMenu, {
|
|
4256
|
+
events: [...new Set([...byResource.values()].flat().map((pe) => pe.event))].filter((event) => editActions(event).length > 0),
|
|
4257
|
+
label: labels.editEvents,
|
|
4258
|
+
labelFor: (event) => labels.eventActions(event.title ?? ""),
|
|
4259
|
+
descriptionFor: eventDescription,
|
|
4260
|
+
onSelect: eventActions.select,
|
|
4261
|
+
rootRef: eventActions.rootRef,
|
|
4262
|
+
slot,
|
|
4263
|
+
theme
|
|
3510
4264
|
}),
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
flex: "none"
|
|
3514
|
-
} }) }), resources.map((resource, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3515
|
-
...slot("resourceLabel", {
|
|
4265
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4266
|
+
...slot("header", {
|
|
3516
4267
|
base: {
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
overflow: "hidden",
|
|
3522
|
-
textOverflow: "ellipsis",
|
|
3523
|
-
whiteSpace: "nowrap",
|
|
3524
|
-
boxSizing: "border-box"
|
|
4268
|
+
display: "flex",
|
|
4269
|
+
position: "sticky",
|
|
4270
|
+
top: 0,
|
|
4271
|
+
zIndex: 2
|
|
3525
4272
|
},
|
|
3526
4273
|
themed: {
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
borderLeft: `1px solid ${theme.gridLine}`
|
|
4274
|
+
borderBottom: `1px solid ${theme.gridLine}`,
|
|
4275
|
+
background: theme.surface
|
|
3530
4276
|
}
|
|
3531
4277
|
}),
|
|
3532
|
-
children:
|
|
3533
|
-
}, resource.id))]
|
|
3534
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3535
|
-
style: { display: "flex" },
|
|
3536
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3537
|
-
...slot("timeAxis", { base: {
|
|
3538
|
-
position: "relative",
|
|
4278
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ...slot("corner", { base: {
|
|
3539
4279
|
width: GUTTER_WIDTH,
|
|
3540
|
-
flex: "none"
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
children: hours.map((h) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3544
|
-
...slot("hourTick", {
|
|
4280
|
+
flex: "none"
|
|
4281
|
+
} }) }), resources.map((resource, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4282
|
+
...slot("resourceLabel", {
|
|
3545
4283
|
base: {
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
4284
|
+
flex: 1,
|
|
4285
|
+
minWidth: 0,
|
|
4286
|
+
padding: "6px 4px",
|
|
4287
|
+
textAlign: "center",
|
|
4288
|
+
overflow: "hidden",
|
|
4289
|
+
textOverflow: "ellipsis",
|
|
4290
|
+
whiteSpace: "nowrap",
|
|
4291
|
+
boxSizing: "border-box"
|
|
3549
4292
|
},
|
|
3550
4293
|
themed: {
|
|
3551
|
-
fontSize:
|
|
3552
|
-
|
|
4294
|
+
fontSize: 13,
|
|
4295
|
+
fontWeight: 600,
|
|
4296
|
+
borderLeft: `1px solid ${theme.gridLine}`
|
|
3553
4297
|
}
|
|
3554
4298
|
}),
|
|
3555
|
-
children: (
|
|
3556
|
-
},
|
|
3557
|
-
}),
|
|
4299
|
+
children: renderResourceHeader ? renderResourceHeader(resource, index) : resource.title ?? resource.id
|
|
4300
|
+
}, resource.id))]
|
|
4301
|
+
}),
|
|
4302
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4303
|
+
style: { display: "flex" },
|
|
4304
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4305
|
+
...slot("timeAxis", { base: {
|
|
4306
|
+
position: "relative",
|
|
4307
|
+
width: GUTTER_WIDTH,
|
|
4308
|
+
flex: "none",
|
|
4309
|
+
height: trackHeight
|
|
4310
|
+
} }),
|
|
4311
|
+
children: hours.map((h) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4312
|
+
...slot("hourTick", {
|
|
4313
|
+
base: {
|
|
4314
|
+
position: "absolute",
|
|
4315
|
+
top: Math.max(0, (h - startHour) * hourHeight - 6),
|
|
4316
|
+
right: 6
|
|
4317
|
+
},
|
|
4318
|
+
themed: {
|
|
4319
|
+
fontSize: 10,
|
|
4320
|
+
color: theme.textMuted
|
|
4321
|
+
}
|
|
4322
|
+
}),
|
|
4323
|
+
children: (0, _super_calendar_core.formatHour)(h, { ampm })
|
|
4324
|
+
}, h))
|
|
4325
|
+
}), resources.map((resource) => {
|
|
4326
|
+
const positioned = byResource.get(resource.id) ?? [];
|
|
4327
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4328
|
+
...slot("row", {
|
|
4329
|
+
base: {
|
|
4330
|
+
flex: 1,
|
|
4331
|
+
minWidth: 0,
|
|
4332
|
+
...dragLaneId === resource.id ? {
|
|
4333
|
+
position: "relative",
|
|
4334
|
+
zIndex: 5
|
|
4335
|
+
} : null
|
|
4336
|
+
},
|
|
4337
|
+
themed: { borderLeft: `1px solid ${theme.gridLine}` }
|
|
4338
|
+
}),
|
|
4339
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4340
|
+
"data-resource-id": resource.id,
|
|
4341
|
+
...trackInteractionProps(resource),
|
|
4342
|
+
...slot("track", { base: {
|
|
4343
|
+
position: "relative",
|
|
4344
|
+
height: trackHeight
|
|
4345
|
+
} }),
|
|
4346
|
+
children: [
|
|
4347
|
+
bandsFor(resource).map((b) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4348
|
+
"aria-hidden": true,
|
|
4349
|
+
...slot("businessHours", {
|
|
4350
|
+
base: {
|
|
4351
|
+
position: "absolute",
|
|
4352
|
+
left: 0,
|
|
4353
|
+
right: 0,
|
|
4354
|
+
top: (b.start - startHour) * hourHeight,
|
|
4355
|
+
height: (b.end - b.start) * hourHeight,
|
|
4356
|
+
pointerEvents: "none",
|
|
4357
|
+
zIndex: 0
|
|
4358
|
+
},
|
|
4359
|
+
themed: renderBusinessHours ? void 0 : { background: theme.outsideHoursBackground }
|
|
4360
|
+
}),
|
|
4361
|
+
children: renderBusinessHours?.({
|
|
4362
|
+
date,
|
|
4363
|
+
start: b.start,
|
|
4364
|
+
end: b.end,
|
|
4365
|
+
resource
|
|
4366
|
+
})
|
|
4367
|
+
}, b.start)),
|
|
4368
|
+
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4369
|
+
"aria-hidden": true,
|
|
4370
|
+
title: b.event.title,
|
|
4371
|
+
...slot("backgroundEvent", {
|
|
4372
|
+
base: {
|
|
4373
|
+
position: "absolute",
|
|
4374
|
+
left: 0,
|
|
4375
|
+
right: 0,
|
|
4376
|
+
top: (b.startHours - startHour) * hourHeight,
|
|
4377
|
+
height: (b.endHours - b.startHours) * hourHeight,
|
|
4378
|
+
pointerEvents: "none",
|
|
4379
|
+
zIndex: 0
|
|
4380
|
+
},
|
|
4381
|
+
themed: { background: theme.backgroundEvent }
|
|
4382
|
+
})
|
|
4383
|
+
}, `bg-${i}`)),
|
|
4384
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4385
|
+
"aria-hidden": true,
|
|
4386
|
+
...slot("gridLines", {
|
|
4387
|
+
base: {
|
|
4388
|
+
position: "absolute",
|
|
4389
|
+
inset: 0,
|
|
4390
|
+
pointerEvents: "none"
|
|
4391
|
+
},
|
|
4392
|
+
themed: { backgroundImage: vGridLines }
|
|
4393
|
+
})
|
|
4394
|
+
}),
|
|
4395
|
+
positioned.map((pe) => {
|
|
4396
|
+
const key = eventKey(pe.event);
|
|
4397
|
+
const active = drag?.event === pe.event && drag.resource.id === resource.id ? drag : null;
|
|
4398
|
+
const startH = active ? active.startHours : pe.startHours;
|
|
4399
|
+
const durH = active ? active.durationHours : pe.durationHours;
|
|
4400
|
+
const top = clamp(startH - startHour, 0, endHour - startHour) * hourHeight;
|
|
4401
|
+
const bottom = clamp(startH + durH - startHour, 0, endHour - startHour) * hourHeight;
|
|
4402
|
+
const height = Math.max(bottom - top, 2);
|
|
4403
|
+
const lanePct = 100 / pe.columns;
|
|
4404
|
+
const onPress = () => onPressEvent?.(pe.event);
|
|
4405
|
+
const args = {
|
|
4406
|
+
event: pe.event,
|
|
4407
|
+
width: 0,
|
|
4408
|
+
height,
|
|
4409
|
+
onPress
|
|
4410
|
+
};
|
|
4411
|
+
const draggable = !!onDragEvent && pe.event.draggable !== false;
|
|
4412
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
4413
|
+
type: "button",
|
|
4414
|
+
onClick: (e) => {
|
|
4415
|
+
if (e.detail !== 0 && handledClick.current === e.currentTarget) {
|
|
4416
|
+
handledClick.current = null;
|
|
4417
|
+
return;
|
|
4418
|
+
}
|
|
4419
|
+
if (!draggable || e.detail === 0) onPress();
|
|
4420
|
+
},
|
|
4421
|
+
"aria-label": pe.event.title,
|
|
4422
|
+
...dataState({ "data-dragging": !!active }),
|
|
4423
|
+
onPointerDown: (e) => beginDrag(e, resource, "move", pe),
|
|
4424
|
+
onPointerMove: moveDrag,
|
|
4425
|
+
onPointerUp: endDrag,
|
|
4426
|
+
onPointerCancel: cancelDrag,
|
|
4427
|
+
onLostPointerCapture: cancelDrag,
|
|
4428
|
+
...slot("event", { base: {
|
|
4429
|
+
position: "absolute",
|
|
4430
|
+
top,
|
|
4431
|
+
height,
|
|
4432
|
+
left: `${pe.column * lanePct}%`,
|
|
4433
|
+
width: `${lanePct}%`,
|
|
4434
|
+
transform: active?.kind === "move" ? `translateX(${active.crossPx}px)` : void 0,
|
|
4435
|
+
padding: 1,
|
|
4436
|
+
border: "none",
|
|
4437
|
+
background: "transparent",
|
|
4438
|
+
cursor: draggable ? "grab" : "pointer",
|
|
4439
|
+
touchAction: draggable ? "none" : "auto",
|
|
4440
|
+
font: "inherit",
|
|
4441
|
+
textAlign: "left",
|
|
4442
|
+
boxSizing: "border-box",
|
|
4443
|
+
zIndex: active ? 3 : 1,
|
|
4444
|
+
opacity: active ? .85 : 1
|
|
4445
|
+
} }),
|
|
4446
|
+
children: [Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...args }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultBar, {
|
|
4447
|
+
...args,
|
|
4448
|
+
theme,
|
|
4449
|
+
boxProps: slot("eventBox")
|
|
4450
|
+
}), draggable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4451
|
+
"aria-hidden": true,
|
|
4452
|
+
onPointerDown: (e) => {
|
|
4453
|
+
e.stopPropagation();
|
|
4454
|
+
beginDrag(e, resource, "resize", pe);
|
|
4455
|
+
},
|
|
4456
|
+
style: {
|
|
4457
|
+
position: "absolute",
|
|
4458
|
+
left: 0,
|
|
4459
|
+
right: 0,
|
|
4460
|
+
bottom: 0,
|
|
4461
|
+
height: 8,
|
|
4462
|
+
cursor: "ns-resize",
|
|
4463
|
+
touchAction: "none"
|
|
4464
|
+
}
|
|
4465
|
+
}) : null]
|
|
4466
|
+
}, key);
|
|
4467
|
+
}),
|
|
4468
|
+
nowLine(resource.id),
|
|
4469
|
+
createBox?.resourceKey === resource.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InertDiv, {
|
|
4470
|
+
"aria-hidden": true,
|
|
4471
|
+
inert: !!createRange,
|
|
4472
|
+
...slot("createGhost", {
|
|
4473
|
+
base: {
|
|
4474
|
+
position: "absolute",
|
|
4475
|
+
left: 1,
|
|
4476
|
+
right: 1,
|
|
4477
|
+
top: Math.min(createBox.startPx, createBox.curPx),
|
|
4478
|
+
height: Math.max(Math.abs(createBox.curPx - createBox.startPx), 2),
|
|
4479
|
+
...createRange ? { overflow: "hidden" } : null,
|
|
4480
|
+
opacity: .7,
|
|
4481
|
+
pointerEvents: "none",
|
|
4482
|
+
zIndex: 2
|
|
4483
|
+
},
|
|
4484
|
+
themed: {
|
|
4485
|
+
background: theme.rangeBackground,
|
|
4486
|
+
border: `1px solid ${theme.selectedBackground}`,
|
|
4487
|
+
borderRadius: 6
|
|
4488
|
+
}
|
|
4489
|
+
}),
|
|
4490
|
+
children: createRange && RenderCreateGhost ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderCreateGhost, {
|
|
4491
|
+
start: createRange.start,
|
|
4492
|
+
end: createRange.end,
|
|
4493
|
+
resource
|
|
4494
|
+
}) : null
|
|
4495
|
+
}) : null
|
|
4496
|
+
]
|
|
4497
|
+
})
|
|
4498
|
+
}, resource.id);
|
|
4499
|
+
})]
|
|
4500
|
+
}),
|
|
4501
|
+
actionsDialog
|
|
4502
|
+
]
|
|
4503
|
+
});
|
|
4504
|
+
}
|
|
4505
|
+
const gridLines = `repeating-linear-gradient(to right, transparent 0, transparent ${hourWidth - 1}px, ${theme.gridLine} ${hourWidth - 1}px, ${theme.gridLine} ${hourWidth}px)`;
|
|
4506
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4507
|
+
ref: eventActions.rootRef,
|
|
4508
|
+
tabIndex: -1,
|
|
4509
|
+
className,
|
|
4510
|
+
style: {
|
|
4511
|
+
fontFamily: theme.fontFamily,
|
|
4512
|
+
color: theme.text,
|
|
4513
|
+
overflowX: "auto",
|
|
4514
|
+
...style
|
|
4515
|
+
},
|
|
4516
|
+
children: [
|
|
4517
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EventActionsMenu, {
|
|
4518
|
+
events: [...new Set([...byResource.values()].flat().map((pe) => pe.event))].filter((event) => editActions(event).length > 0),
|
|
4519
|
+
label: labels.editEvents,
|
|
4520
|
+
labelFor: (event) => labels.eventActions(event.title ?? ""),
|
|
4521
|
+
descriptionFor: eventDescription,
|
|
4522
|
+
onSelect: eventActions.select,
|
|
4523
|
+
rootRef: eventActions.rootRef,
|
|
4524
|
+
slot,
|
|
4525
|
+
theme
|
|
4526
|
+
}),
|
|
4527
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4528
|
+
style: { minWidth: labelWidth + trackWidth },
|
|
4529
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4530
|
+
...slot("header", {
|
|
4531
|
+
base: { display: "flex" },
|
|
4532
|
+
themed: { borderBottom: `1px solid ${theme.gridLine}` }
|
|
4533
|
+
}),
|
|
4534
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ...slot("corner", { base: {
|
|
4535
|
+
width: labelWidth,
|
|
4536
|
+
flex: "none"
|
|
4537
|
+
} }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4538
|
+
...slot("timeAxis", { base: {
|
|
4539
|
+
position: "relative",
|
|
4540
|
+
height: 24,
|
|
4541
|
+
width: trackWidth
|
|
4542
|
+
} }),
|
|
4543
|
+
children: hours.map((h) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4544
|
+
...slot("hourTick", {
|
|
4545
|
+
base: {
|
|
4546
|
+
position: "absolute",
|
|
4547
|
+
left: (h - startHour) * hourWidth,
|
|
4548
|
+
top: 4
|
|
4549
|
+
},
|
|
4550
|
+
themed: {
|
|
4551
|
+
fontSize: 10,
|
|
4552
|
+
color: theme.textMuted
|
|
4553
|
+
}
|
|
4554
|
+
}),
|
|
4555
|
+
children: (0, _super_calendar_core.formatHour)(h, { ampm })
|
|
4556
|
+
}, h))
|
|
4557
|
+
})]
|
|
4558
|
+
}), resources.map((resource, index) => {
|
|
3558
4559
|
const positioned = byResource.get(resource.id) ?? [];
|
|
3559
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
4560
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3560
4561
|
...slot("row", {
|
|
3561
4562
|
base: {
|
|
3562
|
-
|
|
3563
|
-
|
|
4563
|
+
display: "flex",
|
|
4564
|
+
height: rowHeight,
|
|
3564
4565
|
...dragLaneId === resource.id ? {
|
|
3565
4566
|
position: "relative",
|
|
3566
4567
|
zIndex: 5
|
|
3567
4568
|
} : null
|
|
3568
4569
|
},
|
|
3569
|
-
themed: {
|
|
4570
|
+
themed: { borderBottom: `1px solid ${theme.gridLine}` }
|
|
3570
4571
|
}),
|
|
3571
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
4572
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4573
|
+
...slot("resourceLabel", {
|
|
4574
|
+
base: {
|
|
4575
|
+
width: labelWidth,
|
|
4576
|
+
flex: "none",
|
|
4577
|
+
display: "flex",
|
|
4578
|
+
alignItems: "center",
|
|
4579
|
+
padding: "0 10px",
|
|
4580
|
+
boxSizing: "border-box"
|
|
4581
|
+
},
|
|
4582
|
+
themed: {
|
|
4583
|
+
fontSize: 13,
|
|
4584
|
+
fontWeight: 600,
|
|
4585
|
+
borderRight: `1px solid ${theme.gridLine}`
|
|
4586
|
+
}
|
|
4587
|
+
}),
|
|
4588
|
+
children: renderResourceHeader ? renderResourceHeader(resource, index) : resource.title ?? resource.id
|
|
4589
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3572
4590
|
"data-resource-id": resource.id,
|
|
3573
4591
|
...trackInteractionProps(resource),
|
|
3574
4592
|
...slot("track", { base: {
|
|
3575
4593
|
position: "relative",
|
|
3576
|
-
|
|
4594
|
+
width: trackWidth
|
|
3577
4595
|
} }),
|
|
3578
4596
|
children: [
|
|
3579
4597
|
bandsFor(resource).map((b) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3581,10 +4599,10 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3581
4599
|
...slot("businessHours", {
|
|
3582
4600
|
base: {
|
|
3583
4601
|
position: "absolute",
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
4602
|
+
top: 0,
|
|
4603
|
+
bottom: 0,
|
|
4604
|
+
left: (b.start - startHour) * hourWidth,
|
|
4605
|
+
width: (b.end - b.start) * hourWidth,
|
|
3588
4606
|
pointerEvents: "none",
|
|
3589
4607
|
zIndex: 0
|
|
3590
4608
|
},
|
|
@@ -3603,10 +4621,10 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3603
4621
|
...slot("backgroundEvent", {
|
|
3604
4622
|
base: {
|
|
3605
4623
|
position: "absolute",
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
4624
|
+
top: 0,
|
|
4625
|
+
bottom: 0,
|
|
4626
|
+
left: (b.startHours - startHour) * hourWidth,
|
|
4627
|
+
width: (b.endHours - b.startHours) * hourWidth,
|
|
3610
4628
|
pointerEvents: "none",
|
|
3611
4629
|
zIndex: 0
|
|
3612
4630
|
},
|
|
@@ -3621,42 +4639,48 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3621
4639
|
inset: 0,
|
|
3622
4640
|
pointerEvents: "none"
|
|
3623
4641
|
},
|
|
3624
|
-
themed: { backgroundImage:
|
|
4642
|
+
themed: { backgroundImage: gridLines }
|
|
3625
4643
|
})
|
|
3626
4644
|
}),
|
|
3627
|
-
positioned.map((pe
|
|
3628
|
-
const key =
|
|
3629
|
-
const active = drag?.
|
|
4645
|
+
positioned.map((pe) => {
|
|
4646
|
+
const key = eventKey(pe.event);
|
|
4647
|
+
const active = drag?.event === pe.event && drag.resource.id === resource.id ? drag : null;
|
|
3630
4648
|
const startH = active ? active.startHours : pe.startHours;
|
|
3631
4649
|
const durH = active ? active.durationHours : pe.durationHours;
|
|
3632
|
-
const
|
|
3633
|
-
const
|
|
3634
|
-
const
|
|
3635
|
-
const
|
|
4650
|
+
const left = clamp(startH - startHour, 0, endHour - startHour) * hourWidth;
|
|
4651
|
+
const right = clamp(startH + durH - startHour, 0, endHour - startHour) * hourWidth;
|
|
4652
|
+
const width = Math.max(right - left, 2);
|
|
4653
|
+
const laneHeight = rowHeight / pe.columns;
|
|
3636
4654
|
const onPress = () => onPressEvent?.(pe.event);
|
|
3637
4655
|
const args = {
|
|
3638
4656
|
event: pe.event,
|
|
3639
|
-
width
|
|
3640
|
-
height,
|
|
4657
|
+
width,
|
|
3641
4658
|
onPress
|
|
3642
4659
|
};
|
|
3643
4660
|
const draggable = !!onDragEvent && pe.event.draggable !== false;
|
|
3644
4661
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3645
4662
|
type: "button",
|
|
3646
|
-
onClick:
|
|
4663
|
+
onClick: (e) => {
|
|
4664
|
+
if (e.detail !== 0 && handledClick.current === e.currentTarget) {
|
|
4665
|
+
handledClick.current = null;
|
|
4666
|
+
return;
|
|
4667
|
+
}
|
|
4668
|
+
if (!draggable || e.detail === 0) onPress();
|
|
4669
|
+
},
|
|
3647
4670
|
"aria-label": pe.event.title,
|
|
3648
4671
|
...dataState({ "data-dragging": !!active }),
|
|
3649
|
-
onPointerDown:
|
|
3650
|
-
onPointerMove:
|
|
3651
|
-
onPointerUp:
|
|
3652
|
-
onPointerCancel:
|
|
4672
|
+
onPointerDown: (e) => beginDrag(e, resource, "move", pe),
|
|
4673
|
+
onPointerMove: moveDrag,
|
|
4674
|
+
onPointerUp: endDrag,
|
|
4675
|
+
onPointerCancel: cancelDrag,
|
|
4676
|
+
onLostPointerCapture: cancelDrag,
|
|
3653
4677
|
...slot("event", { base: {
|
|
3654
4678
|
position: "absolute",
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
transform: active?.kind === "move" ? `
|
|
4679
|
+
left,
|
|
4680
|
+
width,
|
|
4681
|
+
top: pe.column * laneHeight,
|
|
4682
|
+
height: laneHeight,
|
|
4683
|
+
transform: active?.kind === "move" ? `translateY(${active.crossPx}px)` : void 0,
|
|
3660
4684
|
padding: 1,
|
|
3661
4685
|
border: "none",
|
|
3662
4686
|
background: "transparent",
|
|
@@ -3676,30 +4700,32 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3676
4700
|
"aria-hidden": true,
|
|
3677
4701
|
onPointerDown: (e) => {
|
|
3678
4702
|
e.stopPropagation();
|
|
3679
|
-
beginDrag(e,
|
|
4703
|
+
beginDrag(e, resource, "resize", pe);
|
|
3680
4704
|
},
|
|
3681
4705
|
style: {
|
|
3682
4706
|
position: "absolute",
|
|
3683
|
-
|
|
3684
|
-
right: 0,
|
|
4707
|
+
top: 0,
|
|
3685
4708
|
bottom: 0,
|
|
3686
|
-
|
|
3687
|
-
|
|
4709
|
+
right: 0,
|
|
4710
|
+
width: 8,
|
|
4711
|
+
cursor: "ew-resize",
|
|
3688
4712
|
touchAction: "none"
|
|
3689
4713
|
}
|
|
3690
4714
|
}) : null]
|
|
3691
|
-
},
|
|
4715
|
+
}, key);
|
|
3692
4716
|
}),
|
|
3693
4717
|
nowLine(resource.id),
|
|
3694
|
-
createBox?.resourceKey === resource.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
4718
|
+
createBox?.resourceKey === resource.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InertDiv, {
|
|
3695
4719
|
"aria-hidden": true,
|
|
4720
|
+
inert: !!createRange,
|
|
3696
4721
|
...slot("createGhost", {
|
|
3697
4722
|
base: {
|
|
3698
4723
|
position: "absolute",
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
4724
|
+
top: 1,
|
|
4725
|
+
bottom: 1,
|
|
4726
|
+
left: Math.min(createBox.startPx, createBox.curPx),
|
|
4727
|
+
width: Math.max(Math.abs(createBox.curPx - createBox.startPx), 2),
|
|
4728
|
+
...createRange ? { overflow: "hidden" } : null,
|
|
3703
4729
|
opacity: .7,
|
|
3704
4730
|
pointerEvents: "none",
|
|
3705
4731
|
zIndex: 2
|
|
@@ -3709,236 +4735,22 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3709
4735
|
border: `1px solid ${theme.selectedBackground}`,
|
|
3710
4736
|
borderRadius: 6
|
|
3711
4737
|
}
|
|
3712
|
-
})
|
|
4738
|
+
}),
|
|
4739
|
+
children: createRange && RenderCreateGhost ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderCreateGhost, {
|
|
4740
|
+
start: createRange.start,
|
|
4741
|
+
end: createRange.end,
|
|
4742
|
+
resource
|
|
4743
|
+
}) : null
|
|
3713
4744
|
}) : null
|
|
3714
4745
|
]
|
|
3715
|
-
})
|
|
4746
|
+
})]
|
|
3716
4747
|
}, resource.id);
|
|
3717
4748
|
})]
|
|
3718
|
-
})
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
const gridLines = `repeating-linear-gradient(to right, transparent 0, transparent ${hourWidth - 1}px, ${theme.gridLine} ${hourWidth - 1}px, ${theme.gridLine} ${hourWidth}px)`;
|
|
3722
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3723
|
-
className,
|
|
3724
|
-
style: {
|
|
3725
|
-
fontFamily: theme.fontFamily,
|
|
3726
|
-
color: theme.text,
|
|
3727
|
-
overflowX: "auto",
|
|
3728
|
-
...style
|
|
3729
|
-
},
|
|
3730
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3731
|
-
style: { minWidth: labelWidth + trackWidth },
|
|
3732
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3733
|
-
...slot("header", {
|
|
3734
|
-
base: { display: "flex" },
|
|
3735
|
-
themed: { borderBottom: `1px solid ${theme.gridLine}` }
|
|
3736
|
-
}),
|
|
3737
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ...slot("corner", { base: {
|
|
3738
|
-
width: labelWidth,
|
|
3739
|
-
flex: "none"
|
|
3740
|
-
} }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3741
|
-
...slot("timeAxis", { base: {
|
|
3742
|
-
position: "relative",
|
|
3743
|
-
height: 24,
|
|
3744
|
-
width: trackWidth
|
|
3745
|
-
} }),
|
|
3746
|
-
children: hours.map((h) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3747
|
-
...slot("hourTick", {
|
|
3748
|
-
base: {
|
|
3749
|
-
position: "absolute",
|
|
3750
|
-
left: (h - startHour) * hourWidth,
|
|
3751
|
-
top: 4
|
|
3752
|
-
},
|
|
3753
|
-
themed: {
|
|
3754
|
-
fontSize: 10,
|
|
3755
|
-
color: theme.textMuted
|
|
3756
|
-
}
|
|
3757
|
-
}),
|
|
3758
|
-
children: (0, _super_calendar_core.formatHour)(h, { ampm })
|
|
3759
|
-
}, h))
|
|
3760
|
-
})]
|
|
3761
|
-
}), resources.map((resource, index) => {
|
|
3762
|
-
const positioned = byResource.get(resource.id) ?? [];
|
|
3763
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3764
|
-
...slot("row", {
|
|
3765
|
-
base: {
|
|
3766
|
-
display: "flex",
|
|
3767
|
-
height: rowHeight,
|
|
3768
|
-
...dragLaneId === resource.id ? {
|
|
3769
|
-
position: "relative",
|
|
3770
|
-
zIndex: 5
|
|
3771
|
-
} : null
|
|
3772
|
-
},
|
|
3773
|
-
themed: { borderBottom: `1px solid ${theme.gridLine}` }
|
|
3774
|
-
}),
|
|
3775
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3776
|
-
...slot("resourceLabel", {
|
|
3777
|
-
base: {
|
|
3778
|
-
width: labelWidth,
|
|
3779
|
-
flex: "none",
|
|
3780
|
-
display: "flex",
|
|
3781
|
-
alignItems: "center",
|
|
3782
|
-
padding: "0 10px",
|
|
3783
|
-
boxSizing: "border-box"
|
|
3784
|
-
},
|
|
3785
|
-
themed: {
|
|
3786
|
-
fontSize: 13,
|
|
3787
|
-
fontWeight: 600,
|
|
3788
|
-
borderRight: `1px solid ${theme.gridLine}`
|
|
3789
|
-
}
|
|
3790
|
-
}),
|
|
3791
|
-
children: renderResourceHeader ? renderResourceHeader(resource, index) : resource.title ?? resource.id
|
|
3792
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3793
|
-
"data-resource-id": resource.id,
|
|
3794
|
-
...trackInteractionProps(resource),
|
|
3795
|
-
...slot("track", { base: {
|
|
3796
|
-
position: "relative",
|
|
3797
|
-
width: trackWidth
|
|
3798
|
-
} }),
|
|
3799
|
-
children: [
|
|
3800
|
-
bandsFor(resource).map((b) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3801
|
-
"aria-hidden": true,
|
|
3802
|
-
...slot("businessHours", {
|
|
3803
|
-
base: {
|
|
3804
|
-
position: "absolute",
|
|
3805
|
-
top: 0,
|
|
3806
|
-
bottom: 0,
|
|
3807
|
-
left: (b.start - startHour) * hourWidth,
|
|
3808
|
-
width: (b.end - b.start) * hourWidth,
|
|
3809
|
-
pointerEvents: "none",
|
|
3810
|
-
zIndex: 0
|
|
3811
|
-
},
|
|
3812
|
-
themed: renderBusinessHours ? void 0 : { background: theme.outsideHoursBackground }
|
|
3813
|
-
}),
|
|
3814
|
-
children: renderBusinessHours?.({
|
|
3815
|
-
date,
|
|
3816
|
-
start: b.start,
|
|
3817
|
-
end: b.end,
|
|
3818
|
-
resource
|
|
3819
|
-
})
|
|
3820
|
-
}, b.start)),
|
|
3821
|
-
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3822
|
-
"aria-hidden": true,
|
|
3823
|
-
title: b.event.title,
|
|
3824
|
-
...slot("backgroundEvent", {
|
|
3825
|
-
base: {
|
|
3826
|
-
position: "absolute",
|
|
3827
|
-
top: 0,
|
|
3828
|
-
bottom: 0,
|
|
3829
|
-
left: (b.startHours - startHour) * hourWidth,
|
|
3830
|
-
width: (b.endHours - b.startHours) * hourWidth,
|
|
3831
|
-
pointerEvents: "none",
|
|
3832
|
-
zIndex: 0
|
|
3833
|
-
},
|
|
3834
|
-
themed: { background: theme.backgroundEvent }
|
|
3835
|
-
})
|
|
3836
|
-
}, `bg-${i}`)),
|
|
3837
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3838
|
-
"aria-hidden": true,
|
|
3839
|
-
...slot("gridLines", {
|
|
3840
|
-
base: {
|
|
3841
|
-
position: "absolute",
|
|
3842
|
-
inset: 0,
|
|
3843
|
-
pointerEvents: "none"
|
|
3844
|
-
},
|
|
3845
|
-
themed: { backgroundImage: gridLines }
|
|
3846
|
-
})
|
|
3847
|
-
}),
|
|
3848
|
-
positioned.map((pe, idx) => {
|
|
3849
|
-
const key = `${resource.id}:${idx}`;
|
|
3850
|
-
const active = drag?.key === key ? drag : null;
|
|
3851
|
-
const startH = active ? active.startHours : pe.startHours;
|
|
3852
|
-
const durH = active ? active.durationHours : pe.durationHours;
|
|
3853
|
-
const left = clamp(startH - startHour, 0, endHour - startHour) * hourWidth;
|
|
3854
|
-
const right = clamp(startH + durH - startHour, 0, endHour - startHour) * hourWidth;
|
|
3855
|
-
const width = Math.max(right - left, 2);
|
|
3856
|
-
const laneHeight = rowHeight / pe.columns;
|
|
3857
|
-
const onPress = () => onPressEvent?.(pe.event);
|
|
3858
|
-
const args = {
|
|
3859
|
-
event: pe.event,
|
|
3860
|
-
width,
|
|
3861
|
-
onPress
|
|
3862
|
-
};
|
|
3863
|
-
const draggable = !!onDragEvent;
|
|
3864
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3865
|
-
type: "button",
|
|
3866
|
-
onClick: draggable ? void 0 : onPress,
|
|
3867
|
-
"aria-label": pe.event.title,
|
|
3868
|
-
...dataState({ "data-dragging": !!active }),
|
|
3869
|
-
onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe) : void 0,
|
|
3870
|
-
onPointerMove: draggable ? moveDrag : void 0,
|
|
3871
|
-
onPointerUp: draggable ? (e) => endDrag(e, pe.event, resource, onPress) : void 0,
|
|
3872
|
-
onPointerCancel: draggable ? cancelDrag : void 0,
|
|
3873
|
-
...slot("event", { base: {
|
|
3874
|
-
position: "absolute",
|
|
3875
|
-
left,
|
|
3876
|
-
width,
|
|
3877
|
-
top: pe.column * laneHeight,
|
|
3878
|
-
height: laneHeight,
|
|
3879
|
-
transform: active?.kind === "move" ? `translateY(${active.crossPx}px)` : void 0,
|
|
3880
|
-
padding: 1,
|
|
3881
|
-
border: "none",
|
|
3882
|
-
background: "transparent",
|
|
3883
|
-
cursor: draggable ? "grab" : "pointer",
|
|
3884
|
-
touchAction: draggable ? "none" : "auto",
|
|
3885
|
-
font: "inherit",
|
|
3886
|
-
textAlign: "left",
|
|
3887
|
-
boxSizing: "border-box",
|
|
3888
|
-
zIndex: active ? 3 : 1,
|
|
3889
|
-
opacity: active ? .85 : 1
|
|
3890
|
-
} }),
|
|
3891
|
-
children: [Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...args }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultBar, {
|
|
3892
|
-
...args,
|
|
3893
|
-
theme,
|
|
3894
|
-
boxProps: slot("eventBox")
|
|
3895
|
-
}), draggable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3896
|
-
"aria-hidden": true,
|
|
3897
|
-
onPointerDown: (e) => {
|
|
3898
|
-
e.stopPropagation();
|
|
3899
|
-
beginDrag(e, key, resource.id, "resize", pe);
|
|
3900
|
-
},
|
|
3901
|
-
style: {
|
|
3902
|
-
position: "absolute",
|
|
3903
|
-
top: 0,
|
|
3904
|
-
bottom: 0,
|
|
3905
|
-
right: 0,
|
|
3906
|
-
width: 8,
|
|
3907
|
-
cursor: "ew-resize",
|
|
3908
|
-
touchAction: "none"
|
|
3909
|
-
}
|
|
3910
|
-
}) : null]
|
|
3911
|
-
}, idx);
|
|
3912
|
-
}),
|
|
3913
|
-
nowLine(resource.id),
|
|
3914
|
-
createBox?.resourceKey === resource.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3915
|
-
"aria-hidden": true,
|
|
3916
|
-
...slot("createGhost", {
|
|
3917
|
-
base: {
|
|
3918
|
-
position: "absolute",
|
|
3919
|
-
top: 1,
|
|
3920
|
-
bottom: 1,
|
|
3921
|
-
left: Math.min(createBox.startPx, createBox.curPx),
|
|
3922
|
-
width: Math.max(Math.abs(createBox.curPx - createBox.startPx), 2),
|
|
3923
|
-
opacity: .7,
|
|
3924
|
-
pointerEvents: "none",
|
|
3925
|
-
zIndex: 2
|
|
3926
|
-
},
|
|
3927
|
-
themed: {
|
|
3928
|
-
background: theme.rangeBackground,
|
|
3929
|
-
border: `1px solid ${theme.selectedBackground}`,
|
|
3930
|
-
borderRadius: 6
|
|
3931
|
-
}
|
|
3932
|
-
})
|
|
3933
|
-
}) : null
|
|
3934
|
-
]
|
|
3935
|
-
})]
|
|
3936
|
-
}, resource.id);
|
|
3937
|
-
})]
|
|
3938
|
-
})
|
|
4749
|
+
}),
|
|
4750
|
+
actionsDialog
|
|
4751
|
+
]
|
|
3939
4752
|
});
|
|
3940
4753
|
}
|
|
3941
|
-
//#endregion
|
|
3942
4754
|
exports.Agenda = Agenda;
|
|
3943
4755
|
exports.Calendar = Calendar;
|
|
3944
4756
|
exports.DatePicker = DatePicker;
|